【问题标题】:Problems deploying app through heroku on cloud9, gem error通过 cloud9 上的 heroku 部署应用程序时出现问题,gem 错误
【发布时间】:2016-06-03 03:25:50
【问题描述】:

所以我正在尝试部署我的第一个应用程序,但遇到了一些麻烦,看起来我不断收到以下警告,即“Bundler 的运行版本比创建锁定文件的版本旧”。关于如何将更新的 Gemfile.lock 替换为版本控制的任何想法。以下是完整的错误:

kparekh01:~/workspace/hello_app (master) $ git push heroku master
Counting objects: 68, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (57/57), done.
Writing objects: 100% (68/68), 17.20 KiB | 0 bytes/s, done.
Total 68 (delta 3), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.2.4
remote: -----> Installing dependencies using bundler 1.11.2
remote:        Running: bundle install --without development:test --path       vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
remote:        Warning: the running version of Bundler is older than the version that created the lockfile. We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
remote:        You are trying to install in deployment mode after changing
remote:        your Gemfile. Run `bundle install` elsewhere and add the
remote:        updated Gemfile.lock to version control.
remote:        You have added to the Gemfile:  
remote:        * sass-rails (= 5.0.2)
remote:        * uglifier (= 2.5.3)
remote:        * coffee-rails (= 4.1.0)
remote:        * jquery-rails (= 4.0.3)
remote:        * turbolinks (= 2.3.0)
remote:        * jbuilder (= 2.2.3)
remote:        * sdoc (= 0.4.0)
remote:        * sqlite3 (= 1.3.9)
remote:        * byebug (= 3.4.0)
remote:        * web-console (= 2.0.0.beta3)
remote:        * spring (= 1.1.3)
remote:        * pg (= 0.17.1)
remote:        * rails_12factor (= 0.0.2)
remote:        You have deleted from the Gemfile:
remote:        * byebug
remote:        * coffee-rails (~> 4.1.0)
remote:        * jbuilder (~> 2.0)
remote:        * jquery-rails
remote:        * sass-rails (~> 5.0)
remote:        * sdoc (~> 0.4.0)
remote:        * spring
remote:        * sqlite3
remote:        * turbolinks
remote:        * uglifier (>= 1.3.0)
remote:        * web-console (~> 2.0)
remote:        Bundler Output: Warning: the running version of Bundler is older than the version that created the lockfile. We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
remote:        You are trying to install in deployment mode after changing
remote:        your Gemfile. Run `bundle install` elsewhere and add the
remote:        updated Gemfile.lock to version control.
remote:        
remote:        You have added to the Gemfile:
remote:        * sass-rails (= 5.0.2)
remote:        * uglifier (= 2.5.3)
remote:        * coffee-rails (= 4.1.0)
remote:        * jquery-rails (= 4.0.3)
remote:        * turbolinks (= 2.3.0)
remote:        * jbuilder (= 2.2.3)
remote:        * sdoc (= 0.4.0)
remote:        * sqlite3 (= 1.3.9)
remote:        * byebug (= 3.4.0)
remote:        * web-console (= 2.0.0.beta3)
remote:        * spring (= 1.1.3)
remote:        * pg (= 0.17.1)
remote:        * rails_12factor (= 0.0.2)
remote:        
remote:        You have deleted from the Gemfile:
remote:        * byebug
remote:        * coffee-rails (~> 4.1.0)
remote:        * jbuilder (~> 2.0)
remote:        * jquery-rails
remote:        * sass-rails (~> 5.0)
remote:        * sdoc (~> 0.4.0)
remote:        * spring
remote:        * sqlite3
remote:        * turbolinks
remote:        * uglifier (>= 1.3.0)
remote:        * web-console (~> 2.0)
remote:  !
remote:  !     Failed to install gems via Bundler.
remote:  !
remote: 
remote:  !     Push rejected, failed to compile Ruby app
remote: 
remote: Verifying deploy....
remote: 
remote: !       Push rejected to murmuring-forest-66232.
remote: 
To https://git.heroku.com/murmuring-forest-66232.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/murmuring-forest-   66232.git'

【问题讨论】:

  • 看起来您对 Gemfile 进行了一些更改,但之后没有运行 bundle install,这会更新 Gemfile.lock。做bundle install可以解决你的问题
  • 感谢您的回答,但完全按照建议进行,但仍然收到相同的错误消息。还有什么?
  • 您是否也通过gem install bundler 更新了您的捆绑程序?您还可以删除 gemfile.lock 并运行 bundle install ,这将重新创建 gemfile.lock

标签: ruby-on-rails git heroku deployment rubygems


【解决方案1】:

首先使用

确保您的捆绑器是最新的

`gem install bundler'

接下来再次运行您的捆绑安装并确保它完成。此问题的主要原因是 gem 文件和锁定文件不匹配。捆绑器是更新锁定文件的工具。

【讨论】:

    【解决方案2】:

    警告消息说您需要运行 gem install bundler 才能获取最新版本的捆绑程序。一旦你这样做了bundle install,这将更新你的 Gemfile.lock,它应该被推送到你的存储库。我会推荐阅读这个SO post 以了解更多关于 Gemfile 和 Gemfile.lock 的信息

    【讨论】:

      【解决方案3】:

      您可以解决您的错误,并且可以在更新您的捆绑包后将您的应用程序上传到 heroku。要安装和更新捆绑包,请使用以下命令。

      $ bundle install 
      
      $ bundle update
      

      这是您每次对 gem 文件进行任何更改时都必须遵循的常规过程,以使您的应用程序能够了解您在 gem 文件中所做的新编​​辑。

      【讨论】:

      • 所以我尝试了板上各种版本的建议,但没有任何效果。以下是导致主要错误的原因:远程:-----> 使用 Ruby 版本:ruby-2.2.4 远程:-----> 使用捆绑程序 1.11.2 安装依赖项。 --> 实际上我的 gem 锁文件与 1.12.5 捆绑在一起。如何将捆绑程序的版本更改为 1.11.2,它应该停止给出此错误?任何想法,提前谢谢。
      【解决方案4】:

      没关系,终于发现我的错误了,这很简单。我正确安装并更新了所有内容,但由于我在 cloud 9 ide 上执行此操作,因此我不得不 git add、git commit 和 git push 我的更改,只要我活着,我就永远不会再忘记这一点。感谢大家的帮助。

      【讨论】:

      • 是的,你必须使用 git add . git commit -am "some comment" git push heroku master 命令才能看到 heroku 上的变化。
      猜你喜欢
      • 2021-03-25
      • 1970-01-01
      • 2013-09-30
      • 2011-05-15
      • 1970-01-01
      • 1970-01-01
      • 2015-02-25
      • 2017-02-04
      • 2013-02-15
      相关资源
      最近更新 更多