通过unicorn或thin运行RoR2应用程序会导致gem丢失错误

时间:2013-07-28 07:58:54

标签: ruby-on-rails ruby ruby-on-rails-2

喂,

以下问题最近一直困扰着我。我无法确切地知道它存在的确切原因。

我有一个Rails 2应用程序,特别是Rails 2.3.5,我试图在运行Ubuntu 10.10的开发机器上部署。据我所知,我已经正确地设置了一切。这是一些证据:

ayaz@ubuntu$ rails -v
Rails 2.3.5
ayaz@ubuntu$ gem -v
1.3.7
ayaz@ubuntu$ ruby -v
ruby 1.8.7 (2010-06-23 patchlevel 299) [i686-linux]
ayaz@ubuntu$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.7
  - RUBY VERSION: 1.8.7 (2010-06-23 patchlevel 299) [i686-linux]
  - INSTALLATION DIRECTORY: /var/lib/gems/1.8
  - RUBY EXECUTABLE: /usr/bin/ruby1.8
  - EXECUTABLE DIRECTORY: /var/lib/gems/1.8/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-linux
  - GEM PATHS:
     - /var/lib/gems/1.8
     - /home/ayaz/.gem/ruby/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/
ayaz@ubuntu$ gem list

*** LOCAL GEMS ***

actionmailer (2.3.5)
actionpack (2.3.5)
activerecord (2.3.5)
activeresource (2.3.5)
activesupport (2.3.5)
atomic (1.1.10)
daemons (1.1.9)
eventmachine (1.0.3)
i18n (0.6.4)
kgio (2.8.0)
minitest (4.7.5)
multi_json (1.7.7)
rack (1.5.2, 1.0.1)
rails (2.3.5)
raindrops (0.11.0)
rake (10.1.0)
thin (1.5.1)
thread_safe (0.1.2)
tzinfo (0.3.37)
unicorn (4.6.3)

如果我通过script/server运行应用程序,它运行良好:

ayaz@ubuntu$ script/server 
=> Booting WEBrick
=> Rails 2.3.5 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2013-07-28 01:10:37] INFO  WEBrick 1.3.1
[2013-07-28 01:10:37] INFO  ruby 1.8.7 (2010-06-23) [i686-linux]

但是,如果我通过unicornthin运行它,我会不断收到gem错误:

ayaz@ubuntu$ thin start
>> Using rails adapter
Missing the Rails 2.3.5 gem. Please `gem install -v=2.3.5 rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.

unicorn_rails给出了同样的错误。现在,我环顾四周,找到了关于事先添加require "rubygems"的建议。我试过了:我在config/boot.rbconfig/environment.rb的顶部添加了这一行,但无济于事。

请问有人能指出我正确的方向吗?

非常感谢!

1 个答案:

答案 0 :(得分:0)

我希望您运行多个版本的ruby / ruby​​gems(例如通过RVM或rbenv)。这可能有助于您确定实际使用的红宝石:

which ruby

which gem