ruby on rail部署问题 - 您已经激活了机架1.5.1,但您的Gemfile需要机架1.4.4。使用bundle exec可以解决这个问题

时间:2013-01-31 05:05:34

标签: ruby-on-rails ruby thin

我尝试在轻薄的rails应用程序上部署ruby。我收到了这个错误

/usr/local/rvm/gems/ruby-1.9.3-p125@global/gems/bundler-1.2.0/lib/bundler/runtime.rb:31:in `block in setup': You have already activated rack 1.5.1, but your Gemfile requires rack 1.4.4. Using bundle exec may solve this. (Gem::LoadError)
        from /usr/local/rvm/gems/ruby-1.9.3-p125@global/gems/bundler-1.2.0/lib/bundler/runtime.rb:17:in `setup'
        from /usr/local/rvm/gems/ruby-1.9.3-p125@global/gems/bundler-1.2.0/lib/bundler.rb:116:in `setup'
        from /usr/local/rvm/gems/ruby-1.9.3-p125@global/gems/bundler-1.2.0/lib/bundler/setup.rb:7:in `<top (required)>'
        from /usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from /usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from /var/www/rails/mgm/config/boot.rb:6:in `<top (required)>'
        from /usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from /usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from /var/www/rails/mgm/config/application.rb:1:in `<top (required)>'
        from /usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from /usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from /var/www/rails/mgm/config/environment.rb:2:in `<top (required)>'
        from /usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from /usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from /var/www/rails/mgm/config.ru:3:in `block in <main>'
        from /usr/local/rvm/gems/ruby-1.9.3-p125/gems/rack-1.5.1/lib/rack/builder.rb:55:in `instance_eval'
        from /usr/local/rvm/gems/ruby-1.9.3-p125/gems/rack-1.5.1/lib/rack/builder.rb:55:in `initialize'
        from /var/www/rails/mgm/config.ru:1:in `new'
        from /var/www/rails/mgm/config.ru:1:in `<main>'
        from /usr/local/rvm/gems/ruby-1.9.3-p125/gems/thin-1.5.0/lib/rack/adapter/loader.rb:33:in `eval'
        from /usr/local/rvm/gems/ruby-1.9.3-p125/gems/thin-1.5.0/lib/rack/adapter/loader.rb:33:in `load'
        from /usr/local/rvm/gems/ruby-1.9.3-p125/gems/thin-1.5.0/lib/rack/adapter/loader.rb:42:in `for'
        from /usr/local/rvm/gems/ruby-1.9.3-p125/gems/thin-1.5.0/lib/thin/controllers/controller.rb:169:in `load_adapter'
        from /usr/local/rvm/gems/ruby-1.9.3-p125/gems/thin-1.5.0/lib/thin/controllers/controller.rb:73:in `start'
        from /usr/local/rvm/gems/ruby-1.9.3-p125/gems/thin-1.5.0/lib/thin/runner.rb:187:in `run_command'
        from /usr/local/rvm/gems/ruby-1.9.3-p125/gems/thin-1.5.0/lib/thin/runner.rb:152:in `run!'
        from /usr/local/rvm/gems/ruby-1.9.3-p125/gems/thin-1.5.0/bin/thin:6:in `<top (required)>'
        from /usr/local/rvm/gems/ruby-1.9.3-p125/bin/thin:19:in `load'
        from /usr/local/rvm/gems/ruby-1.9.3-p125/bin/thin:19:in `<main>'
        from /usr/local/rvm/gems/ruby-1.9.3-p125/bin/ruby_noexec_wrapper:14:in `eval'
        from /usr/local/rvm/gems/ruby-1.9.3-p125/bin/ruby_noexec_wrapper:14:in `<main>'

我添加到Gemfile

 gem 'rack' '1.5.1'

然后跑

bundle update rack

我收到了以下错误

Bundler could not find compatible versions for gem "rack":
  In Gemfile:
    rails (= 3.2.8) ruby depends on
      rack (~> 1.4.0) ruby

    rack (1.5.1)

我跑了

 bundle exec

返回

bundler: exec needs a command to run

2 个答案:

答案 0 :(得分:6)

尝试使用

卸载机架
gem uninstall rack 

并运行

bundle install

答案 1 :(得分:0)

您可以使用此命令:

bundle update