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

℡╲_俬逩灬. 提交于 2019-12-02 09:54:32

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.

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