LoginSignup
0
0

More than 3 years have passed since last update.

RailsのアプリをHerokuにデプロイした時のエラー解決(自分用メモ)

Last updated at Posted at 2019-09-30

環境

Ruby 2.6.1
Ruby on Rails 5.2.3

2019.9.30現在

問題1

Herokuにデプロイする際に言われたこと

ターミナル

remote:  !
remote:  !     Could not detect rake tasks
remote:  !     ensure you can run `$ bundle exec rake -P` against your app
remote:  !     and using the production group of your Gemfile.
remote:  !     Activating bundler (2.0.1) failed:
remote:  !     Could not find 'bundler' (2.0.1) required by your /tmp/build_d954aa4ae56d81a84f1107b3fad374d5/Gemfile.lock.
remote:  !     To update to the latest version installed on your system, run `bundle update --bundler`.
remote:  !     To install the missing version, run `gem install bundler:2.0.1`
remote:  !     Checked in 'GEM_PATH=/tmp/build_d954aa4ae56d81a84f1107b3fad374d5/vendor/bundle/ruby/2.6.0', execute `gem env` for more information
remote:  !     
remote:  !     To install the version of bundler this project requires, run `gem install bundler -v '2.0.1'`
remote:  !

これでherokuにデプロイが失敗。
Herokuが bundler 2.0.2 に対応していない??
ここがちょっとわかりませんでしたが2.0.1をインストールと言われたので

$ bundle install -v 2.0.1 

bundler 2.0.1 をインストール

もう一度herokuに

$ git push heroku master

しかし、同じエラーが起きて失敗
結局、bundler 1.17.3 を使いました。

$ bundle _1.17.3_ install

bundler 1.17.3 だといけました!

※もしかしたら、Gemfile.lockで2.0.1なのに、2.0.2だったのが問題だったのかもしれないです。
わかるかたコメントください!!

問題2

remote:  !
remote:  !     Precompiling assets failed.
remote:  !

この上の方にエラー文がありました。

remote:        Uglifier::Error: Unexpected token: name (w). To use ES6 syntax, harmony mode must be enabled with Uglifier.new(:harmony => true).

従って

config/environments/pruduction.rb
config.assets.js_compressor = :uglifier
                  ↓↓↓↓↓↓
config.assets.js_compressor = Uglifier.new(harmony: true)

イコールの後ろを変える。
Uglifierの「U」は大文字なのとシンボルは要らなくなるので注意

さらに上と同じファイル内に

config/environments/pruduction.rb
config.assets.initialize_on_precompile = false

を追加します。

$ git push heroku master
remote:        https://アプリ.herokuapp.com/ deployed to Heroku

これにてアプリがデプロイできました!!

追記

remote:        Sass::SyntaxError: Invalid CSS after "}": expected "}", was ""

一番最後にこのエラーが出てしまいましたがscss内でどこか "}" が抜けていました、、、

参考

https://qiita.com/pokohide/items/017afa5be3b7dc200a8d
https://qiita.com/Kohei_Kishimoto0214/items/1da88849eb298de7f9a6

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0