Rails错误混乱 - 源文件丢失,但是哪一个?我该怎么知道?

时间:2010-12-04 18:36:26

标签: ruby-on-rails passenger

我发现错误的错误信息非常令人困惑,也许我找不到正确的地方,但几乎每一个我偶然发现的错误都会得到同样的信息。

寻求指导!

我通过SSH进入服务器,并运行捆绑安装只是为了确保我的capistrano错过了一步,我还做了一个rake db:setup和rake db:migrate RAILS_ENV = production。

此错误消息似乎非常有问题,我甚至没有看到有关哪个文件丢失的提示?

我在rails 3应用程序中运行ubuntu,nginx,phusion,ree:

Error message:
uninitialized constant Bundler
Exception class:
NameError
Application root:
/home/sshuser/domains/example.com/current
Backtrace:
#   File    Line    Location
0   /home/sshuser/domains/example.com/releases/20101205022037/config/boot.rb    9   
1   /usr/local/rvm/rubies/ree-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb   31  in `gem_original_require'
2   /usr/local/rvm/rubies/ree-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb   31  in `require'
3   /home/sshuser/domains/example.com/releases/20101205022037/config/application.rb 1   
4   /usr/local/rvm/rubies/ree-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb   31  in `gem_original_require'
5   /usr/local/rvm/rubies/ree-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb   31  in `require'
6   /home/sshuser/domains/example.com/releases/20101205022037/config/environment.rb 2   
7   /usr/local/rvm/rubies/ree-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb   31  in `gem_original_require'
8   /usr/local/rvm/rubies/ree-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb   31  in `require'
9   config.ru   3   
10  /usr/local/rvm/gems/ree-1.8.7-2010.02/gems/rack-1.2.1/lib/rack/builder.rb   46  in `instance_eval'
11  /usr/local/rvm/gems/ree-1.8.7-2010.02/gems/rack-1.2.1/lib/rack/builder.rb   46  in `initialize'
12  config.ru   1   in `new'
13  config.ru

我的setup_load_paths.rb如下:

if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
  begin
    rvm_path     = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
    rvm_lib_path = File.join(rvm_path, 'lib')
    $LOAD_PATH.unshift rvm_lib_path
    require 'rvm'
    RVM.use_from_path! File.dirname(File.dirname(__FILE__))
  rescue LoadError
    # RVM is unavailable at this point.
    raise "RVM ruby lib is currently unavailable."
  end
end

我的boot.rb看起来像:

要求'rubygems'

# Set up gems listed in the Gemfile.
gemfile = File.expand_path('../../Gemfile', __FILE__)
begin
  ENV['BUNDLE_GEMFILE'] = gemfile
  require 'bundler'
  Bundler.setup
rescue Bundler::GemNotFound => e
  STDERR.puts e.message
  STDERR.puts "Try running `bundle install`."
  exit!
end if File.exist?(gemfile)    

1 个答案:

答案 0 :(得分:1)

错误来自您的config/setup_load_paths.rb。我猜您使用此文件来设置具有RVM支持的乘客。我还猜测它包括两个捆绑包,类似于:

require 'bundler'
require 'bundler/setup'
Bundler.setup

......现在应该只是:

require 'bundler'
Bundler.setup

猜测......如果不是这样,请编辑并将setup_load_paths.rb的内容放入问题中。