我有自己的宝石“RocketRuby”。我把它加载到irb中并且它正在加载它。在早期版本中,我也在我的config.ru中使用它并且它有效。
现在我再次编译它并再次安装它。然后(它仍然在加载irb工作)乘客崩溃并告诉我:
cannot load such file -- rocketruby (LoadError)
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:60:in `require'
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:60:in `rescue in require'
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
config.ru:1:in `block in <main>'
/var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
/var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
config.ru:1:in `new'
config.ru:1:in `<main>'
/var/lib/gems/1.9.1/gems/passenger-4.0.0.rc6/helper-scripts/rack-preloader.rb:82:in `eval'
/var/lib/gems/1.9.1/gems/passenger-4.0.0.rc6/helper-scripts/rack-preloader.rb:82:in `preload_app'
/var/lib/gems/1.9.1/gems/passenger-4.0.0.rc6/helper-scripts/rack-preloader.rb:127:in `<module:App>'
/var/lib/gems/1.9.1/gems/passenger-4.0.0.rc6/helper-scripts/rack-preloader.rb:6:in `<module:PhusionPassenger>'
/var/lib/gems/1.9.1/gems/passenger-4.0.0.rc6/helper-scripts/rack-preloader.rb:5:in `<main>'
config.ru看起来像这样:
require "rocketruby"
require "./shop_of_one.rb"
ShopOfOne.instance
run RocketRuby::RackApplication.new
非常奇怪的是,当这个错误出现时,irb require "rocketruby"
仍然有效。
任何帮助?
答案 0 :(得分:0)
Passenger以其自己的用户身份运行,即使是已加载的apache
用户也不会共享环境。这意味着您的宝石可能在尝试运行时未安装。
使用bundler会解决这个问题,我确信还有其他方法,但添加Gemfile,运行bundle install --deployment
并添加:
require 'rubygems'
require 'bundler'
Bundler.require
到您的机架应用程序的顶部将解决问题。