[SOLUTION] ruby-build failed


#1

Please note that on Debian WSL the error emerges while installing Ruby as per the course instructions:

$ rbenv install 2.6.5 --verbose
/tmp/ruby-build.20191205011245.4900.cqqZRz ~
warning: bzip2 not found; consider installing bzip2 package
Downloading ruby-2.6.5.tar.bz2…
-> https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.5.tar.bz2
tar (child): bzip2: Cannot exec: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
/home/max/.rbenv/plugins/ruby-build/bin/ruby-build: line 213: pushd: ruby-2.6.5: No such file or directory

BUILD FAILED (Debian GNU/Linux 10 using ruby-build 20191124-2-g77e949a)

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

Last 10 log lines:
/tmp/ruby-build.20191205011245.4900.cqqZRz ~
warning: bzip2 not found; consider installing bzip2 package
tar (child): bzip2: Cannot exec: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now

The ruby-build instructions from here suggest the following packages to be installed beforehand:

$ sudo apt install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm5 libgdbm-dev

The problem is libgdbm5 package is not found and the installation fails. sudo apt search libgdbm returns libgdbm6 to be present, so changing 5 to 6 as follows:

$ sudo apt install autoconf bison build-essential libssl-dev libyaml-dev libreadline-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm6 libgdbm-dev

solves the problem thus making

$ rbenv install 2.6.5 --verbose

successfully build and install Ruby.