Ruby-build: Error installing 2.7.1

Created on 21 Aug 2020  路  6Comments  路  Source: rbenv/ruby-build

Hi guys, anyone encountered this issue while installing 2.7.1?

$ rbenv install 2.7.1
Downloading ruby-2.7.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.1.tar.bz2
Installing ruby-2.7.1...

BUILD FAILED (Pop 20.04 using ruby-build 20200224-73-g0a5e059)

Inspect or clean up the working tree at /tmp/ruby-build.20200821113417.841610.nXIFsy
Results logged to /tmp/ruby-build.20200821113417.841610.log

Last 10 log lines:
        LC_CTYPE =
        MFLAGS =
gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

./tool/file2lastrev.rb:6:in `require': cannot load such file -- optparse (LoadError)
        from ./tool/file2lastrev.rb:6:in `<main>'
make: *** [uncommon.mk:1130: revision.tmp] Error 1

Most helpful comment

fixed this by uninstall rbenv and reinstall with homebrew for ubuntu

All 6 comments

Nope!

rbenv install 2.7.1
Downloading ruby-2.7.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.1.tar.bz2
Installing ruby-2.7.1...
ruby-build: using readline from homebrew
Installed ruby-2.7.1 to /Users/hamid/.rbenv/versions/2.7.1

fixed this by uninstall rbenv and reinstall with homebrew for ubuntu

10 days ago I've installed rbenv and ruby-2.7.1 with success as usual. Today, side-by-side I wanted to install ruby-2.7.2 and same error occured.

[09:51] [gencer] [bf ~/.rbenv] $ rbenv install 2.7.2
Downloading ruby-2.7.2.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.2.tar.bz2
Installing ruby-2.7.2...

BUILD FAILED (Ubuntu 20.04 using ruby-build 20201118-6-g4a0c87c)

Inspect or clean up the working tree at /tmp/ruby-build.20201206095154.809205.OWRJt4
Results logged to /tmp/ruby-build.20201206095154.809205.log

Last 10 log lines:
linking shared-object ripper.so
make[2]: Leaving directory '/tmp/ruby-build.20201206095154.809205.OWRJt4/ruby-2.7.2/ext/ripper'
make[2]: Entering directory '/tmp/ruby-build.20201206095154.809205.OWRJt4/ruby-2.7.2'
./tool/file2lastrev.rb:6:in `require': cannot load such file -- optparse (LoadError)
        from ./tool/file2lastrev.rb:6:in `<main>'
make[2]: *** [uncommon.mk:1130: revision.tmp] Error 1
make[2]: Leaving directory '/tmp/ruby-build.20201206095154.809205.OWRJt4/ruby-2.7.2'
make[1]: *** [exts.mk:86: ruby] Error 2
make[1]: Leaving directory '/tmp/ruby-build.20201206095154.809205.OWRJt4/ruby-2.7.2'
make: *** [uncommon.mk:295: build-ext] Error 2

I've pulled all rbenv + ruby-build changes. Not worked.

Manually uninstalling rbenv and reinstalling 2.7.1 and 2.7.2 solved my problem.

ruby-build.20210407222345.480785.log
Looks like I have managed to reproduce this issue. Clean install rbenv and ruby-build then install 3.0.0 and 3.0.1.

Here are steps to reproduce on Ubuntu 20.10 x86_64

  • Remove ~/.rbenv and install rbenv by "Basic GitHub Checkout" method as follows.
$ rm -rf .rbenv/
$ git clone https://github.com/rbenv/rbenv.git ~/.rbenv
Cloning into '/home/yahonda/.rbenv'...
remote: Enumerating objects: 2886, done.
remote: Total 2886 (delta 0), reused 0 (delta 0), pack-reused 2886
Receiving objects: 100% (2886/2886), 562.66 KiB | 2.08 MiB/s, done.
Resolving deltas: 100% (1801/1801), done.
$ cd ~/.rbenv && src/configure && make -C src
make: Entering directory '/home/yahonda/.rbenv/src'
gcc -fPIC     -c -o realpath.o realpath.c
gcc -shared -Wl,-soname,../libexec/rbenv-realpath.dylib  -o ../libexec/rbenv-realpath.dylib realpath.o
make: Leaving directory '/home/yahonda/.rbenv/src'
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.profile
$ ~/.rbenv/bin/rbenv init
# Load rbenv automatically by appending
# the following to ~/.bashrc:

eval "$(rbenv init -)"
$ vi ~/.bashrc # to add `eval "$(rbenv init -)"`
$ exec $SHELL -l
$ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
Checking for `rbenv' in PATH: /home/yahonda/.rbenv/bin/rbenv
Checking for rbenv shims in PATH: OK
Checking `rbenv install' support: not found
Unless you plan to add Ruby versions manually, you should install ruby-build.
Please refer to https://github.com/rbenv/ruby-build#installation

Counting installed Ruby versions: none
  There aren't any Ruby versions installed under `/home/yahonda/.rbenv/versions'.
  You can install Ruby versions like so: rbenv install 2.2.4
Checking RubyGems settings: OK
Auditing installed plugins: OK
  • Install ruby-build as "rbenv plugin" and install Ruby 3.0.0
$ mkdir -p "$(rbenv root)"/plugins
$ git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
Cloning into '/home/yahonda/.rbenv/plugins/ruby-build'...
remote: Enumerating objects: 162, done.
remote: Counting objects: 100% (162/162), done.
remote: Compressing objects: 100% (114/114), done.
remote: Total 11469 (delta 115), reused 73 (delta 39), pack-reused 11307
Receiving objects: 100% (11469/11469), 2.43 MiB | 4.02 MiB/s, done.
Resolving deltas: 100% (7582/7582), done.
$ rbenv install 3.0.0
Downloading ruby-3.0.0.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.0.tar.gz
Installing ruby-3.0.0...
Installed ruby-3.0.0 to /home/yahonda/.rbenv/versions/3.0.0

$ rbenv global 3.0.0
$ which ruby
/home/yahonda/.rbenv/shims/ruby
$ ruby -v
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]
  • Install Ruby 3.0.1 and it gets the error below
$ rbenv install 3.0.1
Downloading ruby-3.0.1.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.1.tar.gz
Installing ruby-3.0.1...

BUILD FAILED (Ubuntu 20.10 using ruby-build 20210405-2-g693a28e)

Inspect or clean up the working tree at /tmp/ruby-build.20210407222345.480785.HSbVgV
Results logged to /tmp/ruby-build.20210407222345.480785.log

Last 10 log lines:
linking shared-object ripper.so
make[2]: Leaving directory '/tmp/ruby-build.20210407222345.480785.HSbVgV/ruby-3.0.1/ext/ripper'
make[2]: Entering directory '/tmp/ruby-build.20210407222345.480785.HSbVgV/ruby-3.0.1'
./tool/file2lastrev.rb:6:in `require': cannot load such file -- optparse (LoadError)
    from ./tool/file2lastrev.rb:6:in `<main>'
make[2]: *** [uncommon.mk:1156: revision.tmp] Error 1
make[2]: Leaving directory '/tmp/ruby-build.20210407222345.480785.HSbVgV/ruby-3.0.1'
make[1]: *** [exts.mk:88: ruby] Error 2
make[1]: Leaving directory '/tmp/ruby-build.20210407222345.480785.HSbVgV/ruby-3.0.1'
make: *** [uncommon.mk:300: build-ext] Error 2
$

It does not reproduce on macOS 11.3 Beta (20E5224a). I do not have other non-beta versions of macOS.

The same for me with Ruby 2.7.3 version. 3.0.1, 2.6.7 and 2.5.9 installed without errors.

The second try to install is successful somewhy.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

CamJN picture CamJN  路  4Comments

snibbets picture snibbets  路  3Comments

florentmorin picture florentmorin  路  5Comments

k0kubun picture k0kubun  路  3Comments

noraj picture noraj  路  4Comments