Which Ruby version am I really running?

2019-01-18 17:59发布

I'm running Ubuntu 12.04 lts, and installed Ruby via RVM.

The problem is, when I type ruby -v into the terminal, it says that my Ruby version is 1.8.7, and using the shotgun gem for Sinatra it says that I'm running Ruby 1.8.7.

When I type rvm list it shows that the only version of Ruby that I have installed is 2.0.0 and it is my current and default version.

I installed Ruby 2.0.0 via RVM and it is the only version I had installed on my machine.

I tried to install Rails 4 but got an error saying that I need Ruby 1.9 or higher.

How do I know what version am I really on, and how do I set 2.0.0 as my only version?

3条回答
贼婆χ
2楼-- · 2019-01-18 18:17

The ruby version 1.8.7 seems to be your system ruby.

Normally you can choose the ruby version you'd like, if you are using rvm with following. Simple change into your directory in a new terminal and type in:

rvm use 2.0.0

You can find more details about rvm here: http://rvm.io Open the website and scroll down, you will see a few helpful links. "Setting up default rubies" for example could help you.

Update: To set the ruby as default:

rvm use 2.0.0 --default
查看更多
我欲成王,谁敢阻挡
3楼-- · 2019-01-18 18:21

On your terminal, try running:

which -a ruby

This will output all the installed Ruby versions (via RVM, or otherwise) on your system in your PATH. If 1.8.7 is your system Ruby version, you can uninstall the system Ruby using:

sudo apt-get purge ruby

Once you have made sure you have Ruby installed via RVM alone, in your login shell you can type:

rvm --default use 2.0.0

You don't need to do this if you have only one Ruby version installed.

If you still face issues with any system Ruby files, try running:

dpkg-query -l '*ruby*'

This will output a bunch of Ruby-related files and packages which are, or were, installed on your system at the system level. Check the status of each to find if any of them is native and is causing issues.

查看更多
Summer. ? 凉城
4楼-- · 2019-01-18 18:40

Run:

rvm get stable --auto-dotfiles

and make sure to read all the outputs. RVM will tell you if something is wrong which, in your case, might be because GEM_HOME is set to something different then PATH.

查看更多
登录 后发表回答