I want to install a recent version of Ruby on Ubuntu 20.04.
But when I run rbenv install -l on my Ubuntu server, I only see old versions of Ruby listed.
Available versions:
1.8.5-p52
...
2.2.7
2.3.0-dev
2.3.0-preview1
2.3.0-preview2
2.3.0
2.3.1
2.3.2
2.3.3
2.3.4
2.4.0-dev
2.4.0-preview1
2.4.0-preview2
2.4.0-preview3
2.4.0-rc1
2.4.0
2.4.1
2.5.0-dev
jruby-1.5.6
jruby-1.6.3
jruby-1.6.4
...
jruby-9.1.8.0
jruby-9.1.9.0-dev
jruby-9.1.9.0
jruby-9.1.10.0
jruby-9.1.11.0
jruby-9.1.12.0
maglev-1.0.0
maglev-1.1.0-dev
maglev-2.0.0-dev
mruby-dev
mruby-1.0.0
mruby-1.1.0
mruby-1.2.0
rbx-2.2.2
rbx-2.2.3
...
rbx-3.79
rbx-3.80
rbx-3.81
rbx-3.82
ree-1.8.7-2011.03
ree-1.8.7-2011.12
ree-1.8.7-2012.01
ree-1.8.7-2012.02
topaz-dev
Compared to when I run it locally on my mac, I see recent versions like 2.7.1.
2.5.8
2.6.6
2.7.1
...
Why don't these new version show on Ubuntu?
I have rbenv 1.1.1 installed on Ubuntu.
This is probably a dumb question but I have little understanding of code below the webdev level.
I ran this command and it solved my problem.
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
Now I see recent versions of Ruby.
Related
I am currently using ruby version 2.7.0 and I want to upgrade to version 3.1.0 in ubuntu 20:04. I have installed ruby 3.1.0 by following Install ruby 3 using rbenv. This is my output of command rbenv versions, seems the installation is completed.
peisen#peisen:~$ rbenv versions
* system (set by /home/peisen/.rbenv/version)
3.1.0
However, when i check my ruby version using ruby -v
peisen#peisen:~$ ruby -v
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux-gnu]
It shows the version is still 2.7.0. I am still a beginner in ubuntu and not sure how to modify this. I followed this post but this did not work for me. Any ideas?
The output
peisen#peisen:~$ rbenv versions
* system (set by /home/peisen/.rbenv/version)
3.1.0
means that you have two versions installed, system Ruby and 3.1.0. The asterisk indicates that system Ruby is still the currently selected version.
To switch to Ruby 3.1.0 globally run:
$ rbenv global 3.1.0
See the docs about rbenv global and other options to set your desired Ruby version.
I've had some problems building older versions of Ruby with ruby-install on Archlinux. I suspect the same is happening with ruby-build. I am seeing the following after trying to install Ruby 2.1.5, 2.1.6, 2.3.0, 2.3.1, 2.3.4.
/usr/include/openssl/asn1_mac.h:10:2: error: #error "This file is obsolete; please update your software."
#error "This file is obsolete; please update your software."
or
ossl_ssl.c:465:38: error: ‘CRYPTO_LOCK_SSL_SESSION’ undeclared
If not already installed you need Open SSL 1.0:
pacman -S openssl-1.0
For installing Ruby 2.3.x the following is needed:
PKG_CONFIG_PATH=/usr/lib/openssl-1.0/pkgconfig ruby-install ruby 2.3.0
I installed 2.3.0, 2.3.1 and 2.3.4 this way.
I'm using ruby-install but the same probably applies to ruby-build (rbenv).
For Ruby 2.1.x and 2.2.x a patch is also needed:
curl -fsSL https://gist.github.com/mislav/055441129184a1512bb5.txt > ruby2.x-openssl.patch
PKG_CONFIG_PATH=/usr/lib/openssl-1.0/pkgconfig ruby-install -p ruby2.x-openssl.patch ruby 2.1.5
I installed 2.1.5 and 2.1.6 this way.
For older versions of Ruby (< 2) a different patch may be needed which can be downloaded here:
https://github.com/rbenv/ruby-build/wiki#openssl-sslv3_method-undeclared-error
Corrupted memory and Segfaults when compiling ruby
If you get segfaults when compiling, it might be because of the latest version of gcc. A workaround is to install an older version and then specify it to ruby-install:
sudo pacman -S gcc5
CC=/usr/sbin/gcc-5 PKG_CONFIG_PATH=/usr/lib/openssl-1.0/pkgconfig ruby-install ruby 2.3.0
Reference: https://github.com/rbenv/ruby-build/issues/1092
Same worked for me with Ruby 2.6 and OpenSSL 1.1 using rvm:
pacman --sync --needed openssl-1.1
PKG_CONFIG_PATH=/usr/lib/openssl-1.1/pkgconfig rvm install 2.6
I am trying to upgrade Ruby because I need to setup a Jekyll template, and I need to latest version to do it. Since I have a Mac running Sierra, I already have Ruby preinstalled as well as the Homebrew installation. When I install it using brew install ruby, it works, but when I check the version, it is still at 2.0.0 instead of 2.3.1 where it should be. Homebrew says I have 2.3.1, but the CLI says I have 2.0.0. I tried to use brew link --override ruby to make it work, but it said everything was working and it got me nowhere.
Use rbenv and plugin ruby-build. It will keep several versions of ruby on the one machine.
After install go to directory with your code, run rbenv install 2.3.1 and create file .ruby-version containing 2.3.1. All scripts running from this directory will use ruby 2.3.1.
Or you will able to set ruby version for all running scripts - rbenv global 2.3.1
I am on a Mac running OSX 10.11 El Capitan. I installed Ruby 2.3.1 via rvm. If I type in the terminal
ruby --version
It says that I am running 2.0.0
But if I type
rvm use 2.3.1
And then
ruby --version
It says that I am running 2.3.1
But next time I open terminal it goes back to 2.0.0
How can I use latest version of Ruby by default?
rvm --default use 2.3.1
Documentation here.
Make a .ruby-version file in a directory of your project and in it put ruby-3.2.1 or which ever version you want
I'm trying to update my version of Ruby using rbenv. Running rbenv install -l lists all the available versions of ruby, with these two as the only 2.1.0 versions
2.1.0-dev
2.1.0-preview1
Which version of Ruby is more recent and, one assumes, more stable.
The most recent stable version is 2.1.1 you can see it here https://www.ruby-lang.org/en/news/2014/02/24/ruby-2-1-1-is-released/