Search code examples
rubyrbenv

rbenv install giving me a Build Failed


I am having issues getting ruby-build to work through rbenv. When I run rbenv install 2.2.2 (or any other version) I get the following output:

Downloading ruby-2.2.4.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.4.tar.bz2 Installing ruby-2.2.4...

BUILD FAILED (Ubuntu 16.04 using ruby-build 20170201-7-g5d62e84)

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

Last 10 log lines: 
removed 'conf17793.dir/conf17793.file' 
removed 'conf17793.file' 
config.guess already exists 
config.sub already exists 
checking build system type... config.sub: too many arguments 
Try `config.sub --help' for more information. 
configure: error: /bin/bash tool/config.sub x86_64-pc-linux-gnu 
removed '/tmp/cg1RYI8Z/dummy.c' removed '/tmp/cg1RYI8Z/dummy.o' failed 
removed 'confdefs.h' removed directory '/opt/rbenv/versions/2.2.4/lib' 
removed directory '/opt/rbenv/versions/2.2.4'

The full logs are not much longer but I will post them here just in case they are relevant:

/tmp/ruby-build.20170227230105.17714 /opt/rbenv
removed 'ruby-2.2.4.tar.bz2'
/tmp/ruby-build.20170227230105.17714/ruby-2.2.4 /tmp/ruby-build.20170227230105.17714 /opt/rbenv
removed 'conf17793'
removed 'conf17793.dir/conf17793.file'
removed 'conf17793.file'
config.guess already exists
config.sub already exists
checking build system type... config.sub: too many arguments
Try `config.sub --help' for more information.
configure: error: /bin/bash tool/config.sub x86_64-pc-linux-gnu
removed '/tmp/cg1RYI8Z/dummy.c'
removed '/tmp/cg1RYI8Z/dummy.o' failed
removed 'confdefs.h'

I searched online and haven't seen anyone else getting this error in relation to ruby-build or rbenv.

I will also explain my setup and how I installed rbenv just to give as much info as possible.

I am running Ubuntu 16.04 and cloned the rbenv repo to my /opt directory. sudo git clone https://github.com/rbenv/rbenv.git /opt. I added the rbenv set up lines to my .proflie file.

export RBENV_ROOT="/opt/rbenv/"
if [ -d "${RBENV_ROOT}" ]; then
    export PATH="${RBENV_ROOT}/bin:${PATH}"
    eval "$(rbenv init -)"
fi

I then cloned the ruby-build repo git clone https://github.com/rbenv/ruby-build.git /opt/rbenv/plugins/ruby-build

I then created a new group called ruby (that my user is in.) and recursively set it as the group for all of /opt/rbenv so now it's owned by root:ruby.

After all that rbenv appears to be working, I can run commands like rbenv versions (It shows system and 1.9.3-p0 which I installed manually) and rbenv local 1.9.3-p0. With no problem. I can also run rbenv install -l and get a full list with no problem so they both appeared to be installed properly.

If anyone can give me any ideas of what might be going wrong when I try to install a ruby version I would greatly appreciate it.


Solution

  • I found the problem. rbenv install downloads the ruby versions specfied then run the ./configure --prefix=/path/to/rbenv/versions/2.2.2. This is the command that was failing. After looking into one of the versions I downloaded that failed installing and going through it's configure script it was using a script called config.guess to determine the system type. This script creates some temporary files and deletes them. This would normally be fine but I have a custom rm command in my path, it does a few things but one of those things is to add the verbose flag. This was muddying the output of the config.guess script and breaking things later in the .configure script that were dependent on the output of this script. I fixed this by removing the verbose flag from my custom rm command and just placing it in a an alias.

    Short answer (TLDR): I had a custom rm command in my path that was breaking stuff.