无法在任何来源中找到定时器-1.1.0(Bundler :: GemNotFound)

时间:2014-05-01 20:49:15

标签: ruby-on-rails rvm capistrano passenger

Phusion Passenger会抛出以下错误:

Could not find timers-1.1.0 in any of the sources (Bundler::GemNotFound)

我真的不确定这个定时器-11.0.0宝石是什么,但我确实有一个名为sidekiq的宝石,当我仔细阅读Gemfile.lock时,我注意到sidekiq依赖于纤维素和赛璐珞取决于定时器(My Gemfile包括sidekiq但不包括其他两个):

sidekiq (2.13.0)
  celluloid (>= 0.14.1)

celluloid (0.14.1)
  timers (>= 1.0.0)

我有一个工作正常的生产服务器,现在我部署了我的第一个登台服务器(来自生产的不同的ip和git分支)。登台分支对于github上的主分支是IDENTICAL。

暂存服务器似乎缺少生产服务器具有的计时器-1.1.0。这真让我困惑。我正在使用RVM。我的capistrano任务包括以下内容:

set :rvm_type, :system
before "deploy", "deploy:create_gemset"

namespace :deploy do
  desc "Create the gemset"
  task :create_gemset do
    run "rvm #{rvm_ruby_string} --create"
  end

 desc "Install the bundle"
  task :bundle do
    run "bundle install --gemfile #{release_path}/Gemfile --without development test"
  end
end

所以我假设当我第一次部署staging时,它会为staging服务器创建一个gemset来镜像生产服务器的gemset,它会运行bundle install以确保staging上的新gemset具有所有的生产服务器的宝石。但显然这没有发生。

我比较了两台服务器:

生产服务器:

$ rvm -v
rvm 1.17.3 (stable)

$ rvm list    
rvm rubies
=* ruby-1.9.3-p327 [ x86_64 ]
# => - current
# =* - current && default
#  * - default

$ rvm info | grep gem
    gem:          "/usr/local/rvm/gems/ruby-1.9.3-p327"
    gem:          "/usr/local/rvm/rubies/ruby-1.9.3-p327/bin/gem"
    rake:         "/usr/local/rvm/gems/ruby-1.9.3-p327@global/bin/rake"
    PATH:         "/usr/local/rvm/gems/ruby-1.9.3-p327/bin:/usr/local/rvm/gems/ruby-1.9.3-p327@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p327/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
    GEM_HOME:     "/usr/local/rvm/gems/ruby-1.9.3-p327"
    GEM_PATH:     "/usr/local/rvm/gems/ruby-1.9.3-p327:/usr/local/rvm/gems/ruby-1.9.3-p327@global"
    gemset:       ""

登台服务器:

$ rvm -v    
rvm 1.21.2 (stable)

$ rvm list    
rvm rubies
   ruby-1.9.3-p0 [ x86_64 ]
   ruby-1.9.3-p194 [ x86_64 ]
=* ruby-1.9.3-p392 [ x86_64 ]
   ruby-1.9.3-p429 [ x86_64 ]
   ruby-2.0.0-p0 [ x86_64 ]
# => - current
# =* - current && default
#  * - default

   $ rvm info | grep gem
    gem:          "/usr/local/rvm/gems/ruby-1.9.3-p392"
    gem:          "/usr/local/rvm/rubies/ruby-1.9.3-p392/bin/gem"
    rake:         "/usr/local/rvm/gems/ruby-1.9.3-p392/bin/rake"
    PATH:         "/usr/local/rvm/gems/ruby-1.9.3-p392/bin:/usr/local/rvm/gems/ruby-1.9.3-p392@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p392/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/myuser/bin"
    GEM_HOME:     "/usr/local/rvm/gems/ruby-1.9.3-p392"
    GEM_PATH:     "/usr/local/rvm/gems/ruby-1.9.3-p392:/usr/local/rvm/gems/ruby-1.9.3-p392@global"
    gemset:       ""

    $ rvm gemset list
    gemsets for ruby-1.9.3-p429 (found in /usr/local/rvm/gems/ruby-1.9.3-p429)
    (default)
    global
    spree_ecommerce
    => MySite

    $ rvm gemdir
   /usr/local/rvm/gems/ruby-1.9.3-p429@MySite

    cd /usr/local/rvm/gems/ruby-1.9.3-p429@MySite
    $ cd gems
    $ ls -l | grep timers                                    
    drwxrwsr-x  4 myuser rvm 4096 Jul 24  2013 timers-1.1.0

    rvm use ruby-1.9.3-p429 --default
    rvm-prompt
    Using /usr/local/rvm/gems/ruby-1.9.3-p429

注意我也尝试在登台服务器上运行bundle install。

我注意到的一件事是Phusion Passenger。我的生产服务器默认ruby版本和乘客配置完全相同:

$ rvm-prompt
ruby-1.9.3-p327

$ cat passenger.conf
PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p327/gems/passenger-3.0.18
PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.3-p327/ruby

$ cat passenger.load
LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p327/gems/passenger-3.0.18/ext/apache2/mod_passenger.so

但是登台服务器是不同的:

$ rvm-prompt
ruby-1.9.3-p429

$ cat passenger.conf
PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12

$ cat passenger.load
LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/ext/apache2/mod_passenger.so

也许乘客在分期时看错了红宝石和宝石?

1 个答案:

答案 0 :(得分:2)

以防其他人有这个问题,确实是错误的乘客。它使用了错误的红宝石版本和红宝石宝石。它使用的ruby / gems版本没有安装timers gem。解决方案是更改apache配置文件以更新乘客以使用正确的ruby / gems:

$ cd /etc/apache2/mods-available
$ sudo vim passenger.conf
<IfModule mod_passenger.c>
 PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p429@MySite/gems/passenger-4.0.41
 PassengerDefaultRuby /usr/local/rvm/wrappers/ruby-1.9.3-p429@MySite/ruby
</IfModule>

$ sudo vim passenger.load
LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p429@MySite/gems/passenger-4.0.41/buildout/apache2/mod_passenger.so
$ sudo a2enmod passenger
$ sudo /etc/init.d/apache2 restart

同时确保乘客宝石确实安装在您正在使用的红宝石/宝石版本中。