Ruby-on-rails 无法加载此类文件 -- 捆绑程序/设置 (LoadError) || 在 Ubuntu 12.04 x32 上部署
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29533933/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
cannot load such file -- bundler/setup (LoadError) || deploy on Ubuntu 12.04 x32
提问by luotao
I try to deploy my rails app with Nginx, passenger on Ubuntu 12.04 x32. after all things is done, I visit my rails app, but it tell me 'We're sorry, but something went wrong.'.
我尝试在 Ubuntu 12.04 x32 上使用 Nginx 部署我的 rails 应用程序,乘客。一切都完成后,我访问了我的 rails 应用程序,但它告诉我“我们很抱歉,但出了点问题。”。
then I cat /var/log/nginx/error.log, I find this lines:
然后我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>'
I use rvm and rbenv
我使用 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)
and I hava already installed bundler
我已经安装了 bundler
$ bundler -v
Bundler version 1.9.2
and here is my gem env:
这是我的宝石环境:
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
have someone experienced same problem? thanks
有人遇到过同样的问题吗?谢谢
update:
my /etc/nginx/nginx.confand /etc/nginx/sites-enabled/blog.conf:
https://gist.github.com/wall2flower/b3f410317585a8803a27https://gist.github.com/wall2flower/72316e8b437d654e7070
更新:我的/etc/nginx/nginx.conf和/etc/nginx/sites-enabled/blog.conf:https:
//gist.github.com/wall2flower/b3f410317585a8803a27 https://gist.github.com/wall2flower/72316e8b437d654e7070
采纳答案by karlingen
You sure have some PATH issues. Inside the /etc/nginx/nginx.conf, for passenger, you should be pointing to the ruby version where bundler is installed.
你肯定有一些 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;
You can check this with the command
您可以使用以下命令检查这一点
$ which ruby
The output of that command should be the one you should enter for passenger_ruby
该命令的输出应该是你应该输入的 passenger_ruby
If you haven't installed bundler yet go ahead and run gem install bundler
如果你还没有安装 bundler 继续运行 gem install bundler
Also make sure that you are setting the environment variable in your server block:
还要确保在服务器块中设置环境变量:
server {
listen 80 default;
server_name blog.wall2flower.me;
root /var/www/blog/current/public;
passenger_enabled on;
}
回答by Karol Wojtaszek
You need to genarate binstubsto fix the problem:
您需要生成binstubs来解决问题:
bundle install --binstubs
回答by richardun
As karlingen notes, the issue is the result of PATH issues, however if you are using RVM, you will want to get your path to the correct ruby another way...
正如 karlingen 所指出的,问题是 PATH 问题的结果,但是如果您使用的是 RVM,您将希望以另一种方式获得正确的 ruby 路径......
Best thing is to follow Passenger's own guide for finding this info:
最好的办法是按照乘客自己的指南来查找此信息:
回答by ?ukasz Ostrowski
try:
尝试:
bundle exec passenger start ...

