Passenger does not recognize locally installed gem, works with packed gems

本秂侑毒 提交于 2019-12-20 07:37:16

问题


This is a production server. I have Passenger installed and it works properly for the most part. However, I always have to pack the gems with the projects. If I don't, I get this error message:

Missing the Rails 2.3.8 gem. Please `gem install -v=2.3.8 rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed. 

gem list --local returns rails 2.3.8 as well as 2.3.5 so the gem is actually not missing. Since I could not resolve this issue, I keep including the rails gem in every project (which results is a properly working application).

Any ideas?

P.S I did try the suggestions of the error message, my config is asking for 2.3.8 which I have installed


回答1:


Make sure you are installing/running the gem command with the same user permission as Passenger.

By default, Passenger runs inside Apache which has superuser privileges. If you type gem install, the Gems will be saved in your user folder unless you are root.




回答2:


If you're installing gems logged in as a normal user (non-root) or without using sudo, your gems go into .gems folder in your home directory (eg. /home/matt/.gems) and Passenger cannot find them.

You can either install them as root/sudo or add your local directory to your GEM_HOME/GEM_PATH. Not sure if this is the best solution, but I put this at the top of config/environment.rb in my application:

if ENV['RAILS_ENV'] == 'production'
  ENV['HOME'] = "/home/matt"
  ENV['GEM_HOME'] = "/home/matt/.gems"
  ENV['GEM_PATH'] = "/home/matt/.gems"
end


来源:https://stackoverflow.com/questions/3921623/passenger-does-not-recognize-locally-installed-gem-works-with-packed-gems

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