Moving to rbenv breaks passenger (nginx)

2019-02-02 01:32发布

问题:

I moved from RVM to rbenv on my production server. I uninstalled rvm using "rvm implode" and installed rbenv, ruby 1.9.2 , rails, passenger and nginx-module. I have not modified my originlal nginx.conf apart from changing the passenger_root as follows:

1st Try:
passenger_root /root/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/passenger-3.0.9;
passenger_ruby /root/.rbenv/versions/1.9.2-p290/bin/ruby;
2nd Try:
passenger_root /root/.rbenv/shims/passenger;
passenger_ruby /root/.rbenv/shims/ruby;

Now, when I try to run my application I see the following error in error.log:

[error] 1291#0: *105 open() "/home/passenger/grabber/current/public/view" failed (2: No such file or directory)

This clearly indicates that passenger has not launched and my rails app is not recognized. When I try to manually start passenger, I get the following error:

   [ pid=17605 thr=70022120 file=utils.rb:176 time=2011-10-23 23:40:41.917 ]: *** Exception LoadError in PhusionPassenger::Rack::ApplicationSpawner (libruby.so.1.9: cannot open shared object file: No such file or directory - /home/passenger/grabber/shared/bundle/ruby/1.9.1/gems/nokogiri-1.5.0/lib/nokogiri/nokogiri.so) (process 17605, thread #<Thread:0x858e7d0>):
from /home/passenger/grabber/shared/bundle/ruby/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require'

I have installed nokogiri several times and I can see nokogiri in my gem list. I am not sure why moving to to rbenv has broken passenger for me.

回答1:

It is possible to use rbenv, nginx and passenger. Some have gone for a system-wide install. http://blakewilliams.me/blog/4-system-wide-rbenv-install

I'm currently testing on my development environment so, assuming you have installed rbenv and have the correct rbenv init in your .bashrc:

gem install passenger
rbenv rehash
sudo bash -c "source ~/.bashrc && passenger-install-nginx-module"

You must gem install passenger to get the shims. Doing bundle install to install passenger won't give you these.

Finally:

passenger-config --root

will give you your passenger_root path and:

rbenv which ruby

your passenger_ruby path.

The passenger shim points to the executable but passenger_root must be a path to the folder. I've tried using the ruby shim but it doesn't work. I've not dug into why yet.

BTW, I do have the nokogiri gem in my Gemfile. Oh, also if you have .rvmrc and/or config/setup_load_paths.rb it should be safe to remove these as passenger autoloads bundler.

I still need to do a bit more testing on this but so far so good.



回答2:

There seems to be no compatibility between passenger and rbenv (make sure you know this before you shoot yourself in the foot) - so I removed rbenv and moved back to RVM...