スポンサーリンク

Herokuへpushするとrails_12factorがFailed to install gems via Bundlerとなるエラー解決

Web開発のエラー解決

いろいろ手を出して何も進まないというカオスな状態です。。

今はRuby on Rails4でアプリを作ってHerokuで確認しようとしているところ。

ドットインストールのHeroku入門をしているとハマったのでメモ。

PC

Failed to install gems via Bundler.

準備ははしょりますが、ローカル環境でRailsアプリができたので、herokuのgitにpushする、という段階です。

$ git push heroku master

pushをしますが、

remote:        * rails_12factor
remote:        Bundler Output: 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:        * rails_12factor
remote:  !
remote:  !     Failed to install gems via Bundler.
remote:  !
remote: 
remote:  !     Push rejected, failed to compile Ruby app

Gemfileに追加した「rails_12factor」のインストールに失敗したのでコンパイルできなかった、と言っています。

解決策

結論から言うと、Gemfile.lockに「rails_12factor」の情報が無い!というエラー。ローカルで一度bundle installすればOK。

まずはGemfileを一旦修正。「group: :production」を削除します。

$ vim Gemfile
gem 'rails_12factor'

Gemをインストール。

$ bundle install
:
Installing rails_12factor 0.0.3
:

インストールされたら、Gemfileを戻しておきます。

$ vim Gemfile
gem 'rails_12factor', group: :production

再びpush!

$ git add .
$ git commit -m "installed rails_12factor"
$ git push heroku master
:
remote:        Installing rails_12factor 0.0.3
:

オッケー!

これだけのことに1時間くらいもがきました。

どなたかの参考になれば幸いです。

ブログランキング、にほんブログ村
ブログランキング・にほんブログ村へ
スポンサーリンク

フォローする

スポンサーリンク