asdf-ruby icon indicating copy to clipboard operation
asdf-ruby copied to clipboard

Installing 2.7 fails on Ubuntu

Open sbungartz opened this issue 5 years ago • 4 comments

The Error

I tried to install Ruby 2.7.2 with asdf version 0.8.0 and asdf-ruby 1eb03d4 on Ubuntu 18.04 and was met with the following error:

$ asdf install ruby 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 18.04 using ruby-build 20201210)

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

Last 10 log lines:
	LC_CTYPE = 
	MFLAGS = 
gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Copyright (C) 2017 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.

./ruby: error while loading shared libraries: libruby.so.2.7: cannot open shared object file: No such file or directory
uncommon.mk:1130: recipe for target 'revision.tmp' failed
make: *** [revision.tmp] Error 127

The Workaround

If anyone else has this problem, I first want to share how I worked around it: I temporarily removed $HOME/.asdf/bin from my PATH. Then, running ~/.asdf/bin/asdf install ruby 2.7.2 worked except now in the very end it could not find asdf:

/home/<user>/.asdf/lib/commands/command-install.bash: line 200: asdf: command not found

With asdf back on my PATH I then ran asdf reshim and now can use Ruby 2.7.2.

What I think is going on

Through lots of fiddling around I have come to the following conclusions and found a workaround to make it work. But there seems to be some misalignment between what asdf does and what this particular installation process needs:

  • The Ruby Make command it tries to run ruby itself.
  • It uses a BASERUBY env variable to find this ruby (See that line in uncommon.mk:1130)
  • That Variable is set to /home/<user>/.asdf/shims/ruby --disable=gems which seems somewhat reasonable
  • When asdf finds an executable with the same name as the shim in the current directory, it uses that one instead of the configured value. This was very surprising to me, and I'm not sure if this is on purpose. You can test this like this:
$ asdf which ruby
/usr/bin/ruby
$ touch ruby
$ chmod +x ruby
$ asdf which ruby
./ruby
  • When the make script tries to call the BASERUBY it invokes the asdf-shim from the build directory. At this point it has already compiled a ruby executable in that directory, so the shim uses this one instead. But since the required shared libraries are not in the library path it fails to run and the installation fails.

I'm not sure if this is a bug in asdf or asdf-ruby but I figured all these details are fairly ruby specifc so I decided to come here first.

Thanks for maintaining this project!

sbungartz avatar Dec 18 '20 13:12 sbungartz

I was missing the following dependencies:

  • libssl-dev
  • zlib1g-dev

After I installed them in Ubuntu 20 via: sudo apt-get install -y libssl-dev zlib1g-dev

I could install ruby 2.7.2 via asdf without issues.

john-schmitz avatar Feb 02 '21 21:02 john-schmitz

~The above workaround (https://github.com/asdf-vm/asdf-ruby/issues/189#issue-770869137) works on Manjaro (and I'll wager it works on Arch, too), so this is not an Ubuntu-specific problem.~ (20230112) Well, it doesn't seem to work anymore, but the suggestion below did work for me--though, I used 2.5.1 instead of system.

vanvoljg avatar Sep 28 '21 17:09 vanvoljg

A perhaps simpler workaround is to run asdf shell ruby system instead of manually manipulating the PATH variable.

That Variable is set to /home/<user>/.asdf/shims/ruby --disable=gems which seems somewhat reasonable

I think it would be better if this was set to the system ruby version. Then it would avoid issue of it trying to use the version that is partially built.

dlech avatar Jan 05 '23 19:01 dlech

Even better workaround:

RUBY_CONFIGURE_OPTS="--with-baseruby=/usr/bin/ruby" asdf install

You can use type -a ruby to find installed versions if /usr/bin/ruby isn't available.

dlech avatar Jan 05 '23 20:01 dlech