asdf-vm / asdf-vm/asdf-ruby

Installing 2.7 fails on Ubuntu

Open
#189 4 comments 8 reactions 0 assignees View on GitHub
Dominant language
Shell
Stars
734
Forks
156
Avg merge
17h 6m
Merged PRs (30d)
1

Description

## 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//.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//.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!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.