【问题标题】:Gemfile error with bundle commands捆绑命令的 Gemfile 错误
【发布时间】:2012-06-05 18:01:55
【问题描述】:

我是应用程序的协作者,我克隆了该应用程序,并且在协作者的计算机上一切运行良好。但是,当我在 Heroku 应用程序的根目录中键入 bundle exec 或 bundle install 时,我收到以下错误:

/Users/jacob/furious-ocean-6331/Gemfile:3:in `evaluate': undefined method `ruby' for # <Bundler::Dsl:0x007fcda31048c0> (NoMethodError)
       /Users/jacob/.rvm/gems/ruby-1.9.3-p194/gems/bundler-1.1.4/lib/bundler/dsl.rb:7:in `instance_eval'
       /Users/jacob/.rvm/gems/ruby-1.9.3-p194/gems/bundler1.1.4/lib/bundler/dsl.rb:7:in `evaluate'
       /Users/jacob/.rvm/gems/ruby-1.9.3-p194/gems/bundler-1.1.4/lib/bundler/definition.rb:18:in `build'
       /Users/jacob/.rvm/gems/ruby-1.9.3-p194/gems/bundler-1.1.4/lib/bundler.rb:135:in `definition'
       /Users/jacob/.rvm/gems/ruby-1.9.3-p194/gems/bundler1.1.4/lib/bundler/cli.rb:220:in `install'
       /Users/jacob/.rvm/gems/ruby-1.9.3-p194/gems/bundler1.1.4/lib/bundler/vendor/thor/task.rb:22:in `run'
       /Users/jacob/.rvm/gems/ruby-1.9.3-p194/gems/bundler-1.1.4/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
       /Users/jacob/.rvm/gems/ruby-1.9.3-p194/gems/bundler-1.1.4/lib/bundler/vendor/thor.rb:263:in `dispatch'
       /Users/jacob/.rvm/gems/ruby-1.9.3-p194/gems/bundler-1.1.4/lib/bundler/vendor/thor/base.rb:386:in `start'
       /Users/jacob/.rvm/gems/ruby-1.9.3-p194/gems/bundler-1.1.4/bin/bundle:13:in `<top (required)>'
       /Users/jacob/.rvm/gems/ruby-1.9.3-p194/bin/bundle:19:in `load'
       /Users/jacob/.rvm/gems/ruby-1.9.3-p194/bin/bundle:19:in `<main>'
       /Users/jacob/.rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `eval'
       /Users/jacob/.rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `<main>'
There was an error in your Gemfile, and Bundler cannot continue.

这是 Gemfile:

source 'https://rubygems.org'

ruby '1.9.3'
gem 'rails', '3.2.2'

# Bundle edge Rails instead: 
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'nokogiri'
gem 'bcrypt-ruby', :require => 'bcrypt'
gem "json", "~> 1.7.3"

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer'

  gem 'uglifier', '>= 1.0.3'
end

gem 'thin'

gem "heroku"

gem 'jquery-rails'

group :development, :test do
    gem 'sqlite3'
end

group :production do
    gem 'pg'
end


# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# To use Jbuilder templates for JSON
# gem 'jbuilder'

# Use unicorn as the app server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'

【问题讨论】:

    标签: heroku bundle nomethoderror gemfile


    【解决方案1】:

    您在 Gemfile 中的 ruby 元素仅适用于 Bundler 的预发布版本,请确保这样做

    gem install bundler --pre

    确保您在预发布版本的 bundler 上运行,该版本添加了对指定 ruby​​ 版本的支持。

    【讨论】:

    • 我知道,但是对于此类关键信息,您需要安装预发布版本的捆绑器这一事实有点远,而且一开始捆绑器受到影响并不明显,我认为问题出在 RubyGems 中。也许我只是一个没有读完的白痴。
    【解决方案2】:

    要解决此问题,请安装 Bundler 1.2.0 的预发布版本。您不能简单地升级到预发布版本。您必须先卸载再安装。

    $ gem uninstall -ax bundler
    $ gem install bundler --pre
    $ bundle --version
    

    然后运行

     $ bundle install
    

    安装 Gemfile 中指定的 gems

    【讨论】:

      【解决方案3】:

      这个方法是从 bundle 1.2 开始添加的:

      http://bundler.io/v1.2/gemfile.html

      确保您的 bundle --version 足够新。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-08-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-05-15
        相关资源
        最近更新 更多