Trouble in understanding what Ruby version I am “a

2019-08-03 23:48发布

I am on Mac OS an I am running Snow Leopard Version 10.6.8. I am using RVM in order to manage my Ruby installations (and so to use the Ruby on Rails framework) but I am in trouble when I see some outputs in the log, mostly related to the current version in use when I get some warning/error message. That is, I previously run these commands in the terminal window:

$ which ruby
/<ABSOLUTE_PATH>/.rvm/rubies/ruby-1.9.2-p290/bin/ruby

$ rvm install 1.9.3
Installing Ruby from source to: /<ABSOLUTE_PATH>/.rvm/rubies/ruby-1.9.3-p0, this may take a while depending on your cpu(s)...
ruby-1.9.3-p0 - #fetching 
...
Fetching yaml-0.1.4.tar.gz to /<ABSOLUTE_PATH>/.rvm/archives
Extracting yaml-0.1.4.tar.gz to /<ABSOLUTE_PATH>/.rvm/src
Configuring yaml in /<ABSOLUTE_PATH>/.rvm/src/yaml-0.1.4.
Compiling yaml in /<ABSOLUTE_PATH>/.rvm/src/yaml-0.1.4.
Installing yaml to /<ABSOLUTE_PATH>/.rvm/usr
ruby-1.9.3-p0 - #configuring 
ruby-1.9.3-p0 - #compiling 
ruby-1.9.3-p0 - #installing 
Removing old Rubygems files...
Installing rubygems-1.8.10 for ruby-1.9.3-p0 ...
Installation of rubygems completed successfully.
ruby-1.9.3-p0 - adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
ruby-1.9.3-p0 - #importing default gemsets (/<ABSOLUTE_PATH>/.rvm/gemsets/)
Install of ruby-1.9.3-p0 - #complete

$ which ruby
/<ABSOLUTE_PATH>/.rvm/rubies/ruby-1.9.2-p290/bin/ruby

$ rvm use --default 1.9.3
Using /<ABSOLUTE_PATH>/.rvm/gems/ruby-1.9.3-p0

$ which ruby
/<ABSOLUTE_PATH>/.rvm/rubies/ruby-1.9.3-p0/bin/ruby

Until here it seems to be OK.

However, when I get some error like in this question related to the DelayedJob gem, I see in the log that the system is using still Ruby 1.9.2-p290:

# Note the 'ruby-1.9.2-p290'
undefined method `send_register_email\' for #<Syck::DomainType:0x00000108e2f870>\n/<ABSOLUTE_PATH>/.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-3.0.1/lib/delayed/performable_mailer.rb:6:in
...

What is wrong? How can I solve the issue?

1条回答
闹够了就滚
2楼-- · 2019-08-04 00:16

as @sarnold suggests you will have to restart any long running processes such as daemons.

Another thing is that if it is running in a cron tab, make sure the cron task is running as the right user. If you set up RVM for a user, and not the system, then root, or any other user than you didn't set up RVM for, will be using system ruby.

You carefully snipped out ""

Note this can easily happen with

sudo rake some:task # that has to do something as root like open a low port or move a file

this will run as root and not do the right RVM sourcing. To fix this, there is

rvmsudo rake some:task
查看更多
登录 后发表回答