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

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

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

Cloud9は、クラウドからのプログラミングが可能になるWebサービス。IDEとしての機能が搭載されており、GitHubやHerokuなど他ツールとの連携も可能です。ブラウザ上で動くため、デバイスに関係なく開発環境を準備できます。

Ruby on Rails

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

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

Q&A

解決済

2回答

2276閲覧

Cloud9、Herokuにデプロイできない

nekoyama141592

総合スコア53

Cloud9

Cloud9は、クラウドからのプログラミングが可能になるWebサービス。IDEとしての機能が搭載されており、GitHubやHerokuなど他ツールとの連携も可能です。ブラウザ上で動くため、デバイスに関係なく開発環境を準備できます。

Ruby on Rails

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

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

0グッド

0クリップ

投稿2021/01/30 11:50

編集2021/01/30 12:01

rails tutorialをやっていたのですがHerokuにデプロイできていないことに気が付きました。3時間ほどGoogleで検索を書けていますが一向に解決しません。具体的に言うとターミナルで
git push heroku masterと打つと

Terminal

1Counting objects: 127, done. 2Compressing objects: 100% (110/110), done. 3Writing objects: 100% (127/127), 153.70 KiB | 3.75 MiB/s, done. 4Total 127 (delta 5), reused 0 (delta 0) 5remote: Compressing source files... done. 6remote: Building source: 7remote: 8remote: -----> Building on the Heroku-20 stack 9remote: ! Warning: Multiple default buildpacks reported the ability to handle this app. The first buildpack in the list below will be used. 10remote: Detected buildpacks: Ruby,Node.js 11remote: See https://devcenter.heroku.com/articles/buildpacks#buildpack-detect-order 12remote: -----> Ruby app detected 13remote: -----> Installing bundler 1.17.3 14remote: -----> Removing BUNDLED WITH version in the Gemfile.lock 15remote: -----> Compiling Ruby/Rails 16remote: Command: 'set -o pipefail; curl -L --fail --retry 5 --retry-delay 1 --connect-timeout 3 --max-time 30 https://s3-external-1.amazonaws.com/heroku-buildpack-ruby/heroku-20/ruby-2.6.3.tgz -s -o - | tar zxf - ' failed on attempt 1 of 3. 17remote: Command: 'set -o pipefail; curl -L --fail --retry 5 --retry-delay 1 --connect-timeout 3 --max-time 30 https://s3-external-1.amazonaws.com/heroku-buildpack-ruby/heroku-20/ruby-2.6.3.tgz -s -o - | tar zxf - ' failed on attempt 2 of 3. 18remote: 19remote: ! 20remote: ! The Ruby version you are trying to install does not exist on this stack. 21remote: ! 22remote: ! You are trying to install ruby-2.6.3 on heroku-20. 23remote: ! 24remote: ! Ruby ruby-2.6.3 is present on the following stacks: 25remote: ! 26remote: ! - cedar-14 27remote: ! - heroku-16 28remote: ! - heroku-18 29remote: ! 30remote: ! Heroku recommends you use the latest supported Ruby version listed here: 31remote: ! https://devcenter.heroku.com/articles/ruby-support#supported-runtimes 32remote: ! 33remote: ! For more information on syntax for declaring a Ruby version see: 34remote: ! https://devcenter.heroku.com/articles/ruby-versions 35remote: ! 36remote: ! Push rejected, failed to compile Ruby app. 37remote: 38remote: ! Push failed 39remote: ! 40remote: ! ## Warning - The same version of this code has already been built: 2dc56620d26562f11b369e73f71139f88b51ad39 41remote: ! 42remote: ! We have detected that you have triggered a build from source code with version 2dc56620d26562f11b369e73f71139f88b51ad39 43remote: ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch. 44remote: ! 45remote: ! If you are developing on a branch and deploying via git you must run: 46remote: ! 47remote: ! git push heroku <branchname>:main 48remote: ! 49remote: ! This article goes into details on the behavior: 50remote: ! https://devcenter.heroku.com/articles/duplicate-build-version 51remote: 52remote: Verifying deploy... 53remote: 54remote: ! Push rejected to damp-inlet-19623. 55remote: 56To https://git.heroku.com/damp-inlet-19623.git 57 ! [remote rejected] master -> master (pre-receive hook declined) 58error: failed to push some refs to 'https://git.heroku.com/damp-inlet-19623.git'

と表示されます。
Gemfileは

source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby '2.6.3' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 6.0.3' # Use sqlite3 as the database for Active Record # gem 'sqlite3', '~> 1.4' # Use Puma as the app server gem 'puma', '~> 4.1' # Use SCSS for stylesheets gem 'sass-rails', '>= 6' # Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker gem 'webpacker', '~> 4.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.2', 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' end group :development do # Access an interactive console on exception pages or by calling 'console' anywhere in the code. gem 'web-console', '>= 3.3.0' gem 'listen', '~> 3.2' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' gem 'spring-watcher-listen', '~> 2.0.0' end group :test do # Adds support for Capybara system testing and selenium driver gem 'capybara', '>= 2.15' gem 'selenium-webdriver' # Easy installation and use of web drivers to run system tests with browsers gem 'webdrivers' end group :production do gem 'pg' end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] gem 'slim-rails' gem 'html2slim' gem 'bcrypt'

で、database.ymlは

default: &default adapter: sqlite3 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> timeout: 5000 development: <<: *default database: db/development.sqlite3 # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. test: <<: *default database: db/test.sqlite3 production: # <<: *default # database: db/production.sqlite3 adapter: postgresql encoding: unicode pool: 5 database: db/production.postgresql

です。
git init
git add -A
git commit
git remote add origin https://github.com/<私のGitHubアカウント名>/hello_app.git
git push origin master
herokuのversion確認、
heroku login --interactive
heroku create
まで完了しております。

どなたか解決方法をご教授いただけると幸いです。

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

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

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

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

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

guest

回答2

0

ベストアンサー

エラーメッセージの下記の部分がそのまんま答えです。
使用しているRubyのバージョンがheroku-20の環境では対応していないそうなのでURLを参考に対応しているバージョンを使うか、対応しているherokuの環境を使うしかないと思います。

remote: ! The Ruby version you are trying to install does not exist on this stack.

remote: !
remote: ! You are trying to install ruby-2.6.3 on heroku-20.
remote: !
remote: ! Ruby ruby-2.6.3 is present on the following stacks:
remote: !
remote: ! - cedar-14
remote: ! - heroku-16
remote: ! - heroku-18
remote: !
remote: ! Heroku recommends you use the latest supported Ruby version listed here:
remote: ! https://devcenter.heroku.com/articles/ruby-support#supported-runtimes
remote: !
remote: ! For more information on syntax for declaring a Ruby version s

投稿2021/01/30 16:07

yu_1985

総合スコア7447

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

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

nekoyama141592

2021/01/31 04:34

(既にheroku createしていたのでアプリを削除し、一から作り直した) 'heroku login --interactive` のあとに 'heroku stack:set heroku-18` でheroku-20からruby2.6.3に対応しているheroku-18に下げて `git push heroku master` でうまくいきました!! yu_1985さん!本当にありがとうございました!!!
guest

0

Railsチュートリアルの本文では、Gemfileからruby '2.6.3'の行を削除するように指示されています。
ですので、stackを下げるのではなく、この指示に従うのがRailsチュートリアルの進め方として最適です。

最後に、Rubyの正確なバージョン番号を指定する行(ruby '2.6.3')をリスト 1.5から削除している点に注意してください。業務でWebサービスを開発する場面では削除しないことをオススメしますが、本チュートリアルでは、この行が残っているとエラーになる可能性が高まります。

https://railstutorial.jp/chapters/beginning?version=6.0#sec-bundler

詳しい内容は以下にまとめたので、こちらをご覧ください。

【初心者向け】RailsチュートリアルでHerokuデプロイ時に「Ruby 2.6.3はインストールできない」と言われたときの適切な対処方法 - Qiita

投稿2021/02/19 22:50

jnchito

総合スコア357

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問