无法加载此类文件 - bundler / setup(LoadError)||部署在Ubuntu 12.04 x32上

时间:2015-04-09 08:51:57

标签: ruby-on-rails nginx gem rubygems passenger

我尝试使用Nginx部署我的rails应用程序,乘客在Ubuntu 12.04 x32上。完成所有事情后,我访问我的rails应用程序,但它告诉我'我们很抱歉,但出了点问题。'

然后我cat /var/log/nginx/error.log,我发现这一行:

Message from application: cannot load such file -- bundler/setup (LoadError)
/home/thomas/.rvm/rubies/ruby-2.0.0-  p643/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/home/thomas/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:278:in `block in run_load_path_setup_code'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:381:in `running_bundler'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:276:in `run_load_path_setup_code'
/usr/share/passenger/helper-scripts/rack-preloader.rb:99:in `preload_app'
/usr/share/passenger/helper-scripts/rack-preloader.rb:157:in `<module:App>'
/usr/share/passenger/helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>'
/usr/share/passenger/helper-scripts/rack-preloader.rb:28:in `<main>'

我使用rvm和rbenv

$ ruby -v
ruby 2.0.0p643 (2015-02-25 revision 49749) [i686-linux]
$ rbenv versions
system
* 2.0.0-p643 (set by /home/thomas/.rbenv/version)

我已经安装了捆绑包

$ bundler -v
Bundler version 1.9.2

这是我的宝石环境:

RubyGems Environment:
  - RUBYGEMS VERSION: 2.4.6
  - RUBY VERSION: 2.0.0 (2015-02-25 patchlevel 643) [i686-linux]
  - INSTALLATION DIRECTORY: /home/thomas/.rvm/gems/ruby-2.0.0-p643
  - RUBY EXECUTABLE: /home/thomas/.rvm/rubies/ruby-2.0.0-p643/bin/ruby
  - EXECUTABLE DIRECTORY: /home/thomas/.rvm/gems/ruby-2.0.0-p643/bin
  - SPEC CACHE DIRECTORY: /home/thomas/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /home/thomas/.rvm/rubies/ruby-2.0.0-p643/etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-linux
  - GEM PATHS:
     - /home/thomas/.rvm/gems/ruby-2.0.0-p643
     - /home/thomas/.rvm/gems/ruby-2.0.0-p643@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /home/thomas/.rvm/gems/ruby-2.0.0-p643/bin
     - /home/thomas/.rvm/gems/ruby-2.0.0-p643@global/bin
     - /home/thomas/.rvm/rubies/ruby-2.0.0-p643/bin
     - /home/thomas/.rvm/bin
     - /home/thomas/.rbenv/bin
     - /home/thomas/.rbenv/shims
     - /home/thomas/.rbenv/bin
     - /usr/local/sbin
     - /usr/local/bin
     - /usr/sbin
     - /usr/bin
     - /sbin
     - /bin
     - /usr/games

有人遇到过同样的问题吗? 感谢

更新: 我的/etc/nginx/nginx.conf/etc/nginx/sites-enabled/blog.confhttps://gist.github.com/wall2flower/b3f410317585a8803a27 https://gist.github.com/wall2flower/72316e8b437d654e7070

4 个答案:

答案 0 :(得分:11)

你确定有一些PATH问题。在/etc/nginx/nginx.conf内,对于乘客,您应该指向安装了bundler的ruby版本。

passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
passenger_ruby /home/thomas/.rvm/wrappers/default/ruby;

您可以使用命令

进行检查
$ which ruby

该命令的输出应该是您应为passenger_ruby

输入的输出

如果您尚未安装捆绑包,请继续运行gem install bundler

还要确保在服务器块中设置环境变量:

server {
  listen 80 default;
  server_name blog.wall2flower.me;
  root /var/www/blog/current/public;
  passenger_enabled on;
}

答案 1 :(得分:5)

您需要根据binstubs来解决问题:

bundle install --binstubs

答案 2 :(得分:1)

尝试:

bundle exec passenger start ...

答案 3 :(得分:1)

正如karlingen指出的那样,问题是PATH问题的结果,但是如果你使用的是RVM,你会希望以另一种方式获得正确的ruby ......

最好的方法是按照Passenger自己的指南查找此信息:

https://www.phusionpassenger.com/library/config/nginx/reference/#setting_correct_passenger_ruby_value