質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.46%
Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Q&A

解決済

1回答

1469閲覧

rails6 herokuへのデプロイ設定

ro-ze

総合スコア2

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

0グッド

0クリップ

投稿2021/08/13 08:49

前提・実現したいこと

初学者です。
初めてアプリを作成しています。
herokuへデプロイしたいのですがエラーが多発して困っています。
出来ればご回答よろしくお願いします。

発生している問題・エラーメッセージ

Total 0 (delta 0), 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.2
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 ["x86_64-darwin-20"] 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 ["x86_64-darwin-20"] 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: !
remote: ! ## Warning - The same version of this code has already been built: e1ef2fb1bbd91133e48bfca4d8d31668a381a842
remote: !
remote: ! We have detected that you have triggered a build from source code with version e1ef2fb1bbd91133e48bfca4d8d31668a381a842
remote: ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote: !
remote: ! If you are developing on a branch and deploying via git you must run
remote: !
remote: ! git push heroku <branchname>:main
remote: !
remote: ! This article goes into details on the behavior:
remote: ! https://devcenter.heroku.com/articles/duplicate-build-version
remote:
remote: Verifying deploy...
remote:
remote: ! Push rejected to アプリ名前.
remote:
To https://git.heroku.com/アプリ名前.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/アプリ名前.git'

エラーメッセージ Failed to install gems via Bundler. ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'https://git.heroku.com/アプリ名前.git'

該当のソースコード

### Gemfile
コード

source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby '3.0.2' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main' gem 'rails', '~> 6.1.4' # Use sqlite3 as the database for Active Record #gem 'sqlite3', '~> 1.4' # Use Puma as the app server gem 'puma', '~> 5.0' # Use SCSS for stylesheets gem 'sass-rails', '>= 6' # Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker gem 'webpacker', '~> 5.0' # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks gem 'turbolinks', '~> 5' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.7' # Use Redis adapter to run Action Cable in production # gem 'redis', '~> 4.0' # Use Active Model has_secure_password # gem 'bcrypt', '~> 3.1.7' # Use Active Storage variant # gem 'image_processing', '~> 1.2' # Reduces boot times through caching; required in config/boot.rb gem 'bootsnap', '>= 1.4.4', require: false group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] gem 'sqlite3', '~> 1.4' end group :development do # Access an interactive console on exception pages or by calling 'console' anywhere in the code. gem 'web-console', '>= 4.1.0' # Display performance information such as SQL time and flame graphs for each request in your browser. # Can be configured to work on production as well see: https://github.com/MiniProfiler/rack-mini-profiler/blob/master/README.md gem 'rack-mini-profiler', '~> 2.0' gem 'listen', '~> 3.3' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' end group :test do # Adds support for Capybara system testing and selenium driver gem 'capybara', '>= 3.26' gem 'selenium-webdriver' # Easy installation and use of web drivers to run system tests with browsers gem 'webdrivers' end group :production do gem 'pg', '1.2.3' end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] Gemfile.look BUNDLED WITH 2.2.21

試したこと

https://qiita.com/m6mmsf/items/fb8a8672df98bdb59c9c
こちらの記事とほぼ同じ内容だったので、ターミナルで実行してみて、bundleのバージョンを変更してみてプッシュしましたが、同じエラーが出ました。

補足情報(FW/ツールのバージョンなど)

記事を見てみたら、「herokuのbundlerとローカルでのbundlerのバージョンに相違がある」ことらしいのでバージョンを記載します。
Bundler version 2.2.21
heroku/7.56.1 darwin-x64 node-v16.6.1

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

この↓エラー(warning)が問題のように見えます。

remote: ! ## Warning - The same version of this code has already been built: e1ef2fb1bbd91133e48bfca4d8d31668a381a842

つまり、そもそもgitで全く同じcommit番号のものがすでにherokuにdeployされているのではないでしょうか。
ローカルで変更したものの、commitしていない場合に同じような問題とエラーに遭遇したことが私もあります。もうすでにdeployされている以上、そのまま重ねてdeployすることは、herokuではできなかったと思います。

herokuへのdeployはgitのmaster branchをお使いのようですから、例えばterminalから、以下のgitコマンドなどで確認するとよいでしょう。

bash

1git switch master 2git status # => 正常ならば nothing to commit などと出るはず(英語環境でのメッセージ) 3git log -n 10 --graph --decorate --pretty=oneline --abbrev-commit 4 # => master と heroku/master とが一致していれば、すでにdeployされていることを意味する

なお、このエラーが解決しても、今度は他のエラーが出てdeploy失敗する可能性は残ります。しかしそれはこの質問とは別の問題になるかと思います。

投稿2021/09/11 20:39

MasaSakano

総合スコア188

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

ro-ze

2021/09/12 02:29

コメントありがとうございます。 こちらを試して見たところ別のエラーが出たので、こちらのhttps://qiita.com/fujiab/items/ca79dabad06bbd75ba39を見て試してみたらデプロイ出来ました。 ありがとうございます。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.46%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問