Home > Software design >  Ruby version showing 2 although Ruby 3 installed
Ruby version showing 2 although Ruby 3 installed

Time:06-27

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?

CodePudding user response:

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.

  •  Tags:  
  • ruby
  • Related