LoginSignup
5
2

More than 3 years have passed since last update.

Rails6 Herokuにデプロイしようとしたらエラーが多発した話

Posted at

前提

オリジナルアプリケーションを開発した後、herokuにデプロイした際にでたエラーを備忘録としてまとめておこうと思います。

結論

  • assetのファイルの場所が違った
  • bundlerのバージョンを合わせた
  • platformを変えた

1つ目

% git heroku push master

実行すると、、、

.
.
.
# 省略
Caused by:
Sass::SyntaxError: File to import not found or unreadable: tagsinput.
.
.
.
remote:  !
remote:  !     Precompiling assets failed.
remote:  !
.
.
.

と表示された。
tagsinput.jsが読み込まれていないとあるので、みてみるとrequire('../tagsinput')をjavastcript/packs/application.jsに記述していなかったのが原因だったっぽい。

2つ目

1つ目のエラーが解消したので成功すると思い、

% git heroku push master

実行すると、、、

.
.         # 省略
.

Bundler Output: Fetching gem metadata from https://rubygems.org/............
Your bundle is locked to mimemagic (0.3.5), but that version could not be found 
in any of the sources listed in your Gemfile. If you haven't changed sources, 
that means the author of mimemagic (0.3.5) has removed it. You'll need to update
your bundle to a version other than mimemagic (0.3.5) that hasn't been removed
in order to install.

remote:  !
remote:  !     Failed to install gems via Bundler.
remote:  !
.
.
.

調べてみたところ、ローカルのbundlerとherokuのbundlerを合わせないといけないらしい、、、
ということでもう一度Terminalを眺めてみると、

Installing bundler 2.2.11

と書いてある
一方ローカルの方でみてみると

% bundler -v
Bundler version 2.1.4

違っていたので、ローカルの方を合わせることにした。

手順としては、
1. 今のローカルにあるbundlerをアンインストール。
2. Herokuに合わせたbundlerのversionをインストール
3. Gemfile.lockを一度削除。
4. Gemfile.lockを再度生成。
5. HerokuへPush
とういことでまず既存のbundlerをアンインストールするため

% gem uninstall bundler

実行し、アンインストールができたら
バージョンを合わせるため、

% gem install bundler --version '2.2.11'

を実行。
インストールできたことを確認したら、Gemfile.lockを削除するため下記を実行。

% rm gemfile.lock

できたら、もう一度Gemfile.lockを生成するためバージョンを指定して下記を実行

% bundle _2.2.11_ install --without production

これでこのエラー解消できた!、、、

3つ目

と思いきやherokuにpushするとさらに追撃が、、、

.
.      # 省略
.

Bundler Output: Your bundle only supports platforms ["x86_64-darwin-20"] but your local platform      
is x86_64-linux. Add the current platform to the lockfile with `bundle lock
--add-platform x86_64-linux` and try again.

remote:  !
remote:  !     Failed to install gems via Bundler.
remote:  !
.
.
.

エラー文に記載された通り、

% bundle lock --add-platform x86_64-linux

実行し、コミットしてプッシュする。
再度

% git push heroku master

実行すると、やっとできた!

少しでも参考になったら幸いです。

参考

5
2
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
5
2