2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Herokuにデプロイまで流れとつまずいたこと

Posted at

はじめに

Ruby on Railsチュートリアルを学習していた際、Herokuにデプロイする時にエラーに苦戦し、情報共有できればと思い記事にしました。

自身のスキル

プログラミングの学習をし始めて2ヶ月になります。 現在Ruby on Railsチュートリアルを中心に学習しています。もし違っているところなどございましたら、ご指摘いただければうれしいです。

自身の開発環境

・Ruby 3.0.3 ・Rails 6.1.4.4 ・エディタ Atom ・m1 mac

Herokuへデプロイを行う流れ

②ステージングエリアへ

$ git add -A

③コミットする

$ git add commit -m"コミットメッセージ"

④Herokuにloginする

$ heroku login

⑤Herokuに新しいアプリケーションを作成する

$ heroku create
$ heroku create アプリ名 ※アプリ名を指定したい時

⑥Herokuへデプロイする

$ git push heroku main

エラーが...

Enumerating objects: 106, done.
Counting objects: 100% (106/106), done.
Delta compression using up to 8 threads
Compressing objects: 100% (87/87), done.
Writing objects: 100% (106/106), 142.35 KiB | 7.12 MiB/s, done.
Total 106 (delta 3), reused 0 (delta 0), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Building on the Heroku-20 stack
remote: -----> Determining which buildpack to use for this app
remote:  !     Warning: Multiple default buildpacks reported the ability to handle this app. The first buildpack in the list below will be used.
remote:                         Detected buildpacks: Ruby,Node.js
remote:                         See https://devcenter.heroku.com/articles/buildpacks#buildpack-detect-order
remote: -----> Ruby app detected
remote: -----> Installing bundler 2.2.21
remote: -----> Removing BUNDLED WITH version in the Gemfile.lock
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-3.0.3
remote: -----> Installing dependencies using bundler 2.2.21
remote:        Running: BUNDLE_WITHOUT='development:test' BUNDLE_PATH=vendor/bundle BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 bundle install -j4
remote:        Your bundle only supports platforms ["arm64-darwin-21"] but your local platform
remote:        is x86_64-linux. Add the current platform to the lockfile with `bundle lock
remote:        --add-platform x86_64-linux` and try again.
remote:        Bundler Output: Your bundle only supports platforms ["arm64-darwin-21"] but your local platform
remote:        is x86_64-linux. Add the current platform to the lockfile with `bundle lock
remote:        --add-platform x86_64-linux` and try again.
remote: 
remote:  !
remote:  !     Failed to install gems via Bundler.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !       Push rejected to アプリ名.
remote: 
To https://git.heroku.com/tw1226hello.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/アプリ名'

⑦エラーないに書いてあるbundle lock --add-platform x86_64-linuxを実行
その後、デプロイ

$ bundle lock --add-platform x86_64-linux
$ git add -A
$ git commit -m "Gemfile.lock fix"
$ git push heroku main

無事にデプロイできました。

2
0
1

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?