Updated Ruby in production and now Rails won't start because still referencing old ruby

只谈情不闲聊 提交于 2019-12-25 00:24:57

问题


Just updated Ruby on a staging server via RVM:

$ rvm upgrade 1.9.3-p327 1.9.3-p362

I said 'yes' to all the migration and alias questions including deleting old Ruby.

Now getting error from Passenger whenever I try to access Rails application:

Error message: 
dlopen(/Library/WebServer/rails/myapp/shared/bundle/ruby/1.9.1/gems/bcrypt-ruby-3.0.1/lib/bcrypt_ext.bundle, 9): 
Library not loaded: /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/libruby.1.9.1.dylib 
Referenced from: /Library/WebServer/rails/myapp/shared/bundle/ruby/1.9.1/gems/bcrypt-ruby-3.0.1/lib/bcrypt_ext.bundle 
Reason: image not found - /Library/WebServer/rails/myapp/shared/bundle/ruby/1.9.1/gems/bcrypt-ruby-3.0.1/lib/bcrypt_ext.bundle

I've re-installed Passenger...and also ran cap deploy with slightly updated Gemfile. but it appears there are still some references to the old Ruby. What's happening here and how can up update, or re-compile, so gems etc reference new Ruby? Is there some flag I can specify in Capistrano that would force the recompiling of gems (assuming that's the problem)?

Edit (adding some RVM info):

I'm using a "Multi-user" installation of RVM on this server and because of that the gems are installed in: /Library/WebServer/rails/popup/shared/bundle/ruby/1.9.1/gems and not where I might have expected them: /usr/local/rvm/rubies/ruby-1.9.3-p362/lib/ruby/gems/1.9.1/gems. Never really understood what RVM was doing in a Multi-user installation but it has worked.

So, poing being I can't really $ rvm gemset use myapp and then bundle install because I don't think that would install in the correct directory.

Here's Capistrano's output during bundle install task:

  * 2013-01-03 19:23:22 executing `bundle:install'
  * executing "cd /Library/WebServer/rails/myapp/releases/20130104032317 && bundle install --gemfile /Library/WebServer/rails/myapp/releases/20130104032317/Gemfile --path /Library/WebServer/rails/myapp/shared/bundle --deployment --quiet --without development test"

回答1:


The error is about /Library/WebServer/rails/myapp/shared/bundle/ruby/1.9.1/gems/bcrypt-ruby-3.0.1/lib/bcrypt_ext.bundle referencing non existing file /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/libruby.1.9.1.dylib this should not happen as in most cases libruby.1.9.1.dylib should be available as already loaded from ruby when it's running. So either you have installed ruby using only static compilation or it might be broken.

Are you sure ruby 1.9.3-p362 is used? RVM provides 1.9.3-p327 for OSX 10.8 which is compiled statically (no package manager issue on OSX). Maybe you used that version(p327) instead?

As for reinstalling the gems - there is not yet a command that would force reinstalling installed gems in bundler, however you can just remove the gems and force installation fresh:

cd /Library/WebServer/rails/myapp/
rm -rf shared/bundle
bundle install



回答2:


Try rvm list to list all your ruby versions

then use rvm use <ruby version> to use that version

Ex:

[sameera@sameera ~]$ rvm list

rvm rubies

     ruby-1.9.2-p290 [ x86_64 ]
=>   ruby-1.8.7-p357 [ x86_64 ]

rvm use rvm use ruby-1.9.2-p290

HTH



来源:https://stackoverflow.com/questions/14150875/updated-ruby-in-production-and-now-rails-wont-start-because-still-referencing-o

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!