I have recently installed both rbenv and ruby-install but I am unable to install any version of Ruby using rbenv install x.x.x command.
I am using Debian 8.3 and rbenv 1.0.0. You can find other information in attached screenshoot.
I received the same "failed to download" error using Ubuntu 14.04. I consulted these directions and the ruby-build wiki.
Update the build environment.
$ sudo apt-get install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev
Download rbenv and ruby-build.
$ git clone git://github.com/sstephenson/rbenv.git
$ git clone git://github.com/sstephenson/ruby-build.git rbenv/plugins/ruby-build
Edit .bashrc:
export PATH=$PATH:~/rbenv/bin
export PATH=$PATH:~/rbenv/plugins/ruby-build/bin
export PATH=~/.gem/ruby/1.9.1/bin/:$PATH
eval "$(rbenv init -)"
Attempt to install the latest version (I tried a few different versions and none worked):
$ rbenv install 2.3.0
Downloading ruby-2.3.0.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.0.tar.bz2
error: failed to download ruby-2.3.0.tar.bz2
BUILD FAILED (Ubuntu 14.04 using ruby-build 20160330-8-gd7668be)
I'm not sure what to try next. The error message doesn't specify any specific problem. A past comment advised trying a different network, but I'm not sure what that means.
@jdblischak Have you try to download tar.bz with binaries manually with wget or curl? I haven't, but now I don't get 'failed to download ruby', and have successfully installed desired Ruby version using 'rbenv install' after machine restart.
Thanks for the suggestion, @alankis. That is in fact what I did. Instead of using rbenv, I downloaded the latest version of ruby and installed from source.
$ wget https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.0.tar.gz
try to add a -v option, like this rbenv install 2.3.1 -v, will print following:
/var/folders/8d/5bz90qjn3s109w_z32b7x92c0000gn/T/ruby-build.20160726102511.63241 ~/Downloads
Downloading ruby-2.2.5.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.5.tar.bz2
07/26 10:25:11 [WARN] Neither --rpc-secret nor a combination of --rpc-user and --rpc-passwd is set. This is insecure. It is extremely recommended to specify --rpc-secret with the adequate secrecy or now deprecated --rpc-user and --rpc-passwd.
07/26 10:25:11 [ERROR] IPv4 RPC: failed to bind TCP port 6800
Exception: [SocketCore.cc:293] errorCode=1 Failed to bind a socket, cause: Address already in use
07/26 10:25:11 [ERROR] IPv6 RPC: failed to bind TCP port 6800
Exception: [SocketCore.cc:293] errorCode=1 Failed to bind a socket, cause: Address already in use
07/26 10:25:11 [ERROR] Exception caught
Exception: [DownloadEngineFactory.cc:215] errorCode=1 Failed to setup RPC server.
error: failed to download ruby-2.2.5.tar.bz2
Oh, looks like port 6800 already used, then you can run lsof -t -i :6800 | xargs kill -9 to kill, and retry, works!
@jdblischak your solution worked for me
Most helpful comment
@jdblischak your solution worked for me