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

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

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

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

Heroku

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

GitHub

GitHubは、Gitバージョン管理システムを利用したソフトウェア開発向けの共有ウェブサービスです。GitHub商用プランおよびオープンソースプロジェクト向けの無料アカウントを提供しています。

Ruby on Rails

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

Q&A

解決済

2回答

1605閲覧

Herokuで デプロイしたいがコマンド打つとエラーが起きる

yoshidesu

総合スコア4

Ruby

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

Heroku

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

GitHub

GitHubは、Gitバージョン管理システムを利用したソフトウェア開発向けの共有ウェブサービスです。GitHub商用プランおよびオープンソースプロジェクト向けの無料アカウントを提供しています。

Ruby on Rails

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

0グッド

0クリップ

投稿2021/08/18 15:48

編集2021/08/19 10:30

お世話になっております。

投稿サイトのようなweb applicationを完成させ、色んな方に見てもらうためにgithub, herokuを用いてデプロイしようと思い、現在作業しています。

git push heroku master というコマンドを打った瞬間に以下のような写真のエラーが起きてしまいました。

イメージ説明

写真で見づらいと思うのですが、ご了承ください。

赤い文字の部分は以下の通りの表記です

remote: ! remote: ! Failed to install gems via Bundler. remote: ! Detected sqlite3 gem which is not supported on Heroku: remote: ! https://devcenter.heroku.com/articles/sqlite3 remote: !
To https://git.heroku.com/sample77tweetapp.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'https://git.heroku.com/sample77tweetapp.git'

自分で既に行ったこと

  1. bundlerのバージョンがherokuのbundlerバージョンとローカルのbundlerのバージョンがあっていないのではと思い、herokuのbundlerバージョンに合わせた (2.2.21)

  2. sqlite3がエラー起こしているのではと思い、こちらの記事を参考にしながらpostgresqlに変更しようとファイルなどを書き換えて見たが、完全に完了したのかどうか分からない (結果としてgit push heroku masterでエラーが未だに起きている状況)

https://qiita.com/hmmrjn/items/e2dff8036fbbd74f049a

です。

これからどのようにエラーに対応すれば良いか分からず、皆様に相談させて頂きました。

どうぞ宜しくお願い致します。。

追加内容

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", group: :development gem "pg", group: :production # 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.11" # 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] 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 # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby] gem "pry-rails"

database.yml

# SQLite. Versions 3.8.0 and up are supported. # gem install sqlite3 # # Ensure the SQLite 3 gem is defined in your Gemfile # gem 'sqlite3' # 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 adapter: postgresql encoding: unicode pool: 5

8/19 18:45現在のエラー表記 (最新、sqliteに関するエラーはクリアした模様)

remote: You have deleted from the Gemfile: remote: * sqlite3 (~> 1.4) remote: Bundler Output: You are trying to install in deployment mode after changing remote: your Gemfile. Run `bundle install` elsewhere and add the remote: updated Gemfile.lock to version control. remote: remote: If this is a development machine, remove the /tmp/build_d55761f7/Gemfile freeze remote: by running ``. remote: remote: The dependencies in your gemfile changed remote: remote: You have added to the Gemfile: remote: * pg (~> 1.1) remote: remote: You have deleted from the Gemfile: remote: * sqlite3 (~> 1.4) 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 sample77tweetapp. remote: To https://git.heroku.com/sample77tweetapp.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'https://git.heroku.com/sample77tweetapp.git'

最後に赤文字で、"failed to install gems via Bundler"の文字がエラーとして出ている状況です

Bundle installをコマンドした後のエラー内容

Yoshihiros-MacBook-Pro:sample_tweetapp yoshi$ bundle install Fetching source index from https://rubygems.org/ Retrying fetcher due to error (2/4): Bundler::HTTPError Could not fetch specs from https://rubygems.org/ due to underlying error <Errno::ECONNREFUSED: Failed to open TCP connection to rubygems.org:443 (Connection refused - connect(2) for "rubygems.org" port 443) (https://rubygems.org/specs.4.8.gz)> Retrying fetcher due to error (3/4): Bundler::HTTPError Could not fetch specs from https://rubygems.org/ due to underlying error <Errno::ECONNREFUSED: Failed to open TCP connection to rubygems.org:443 (Connection refused - connect(2) for "rubygems.org" port 443) (https://rubygems.org/specs.4.8.gz)> Retrying fetcher due to error (4/4): Bundler::HTTPError Could not fetch specs from https://rubygems.org/ due to underlying error <Errno::ECONNREFUSED: Failed to open TCP connection to rubygems.org:443 (Connection refused - connect(2) for "rubygems.org" port 443) (https://rubygems.org/specs.4.8.gz)> Could not fetch specs from https://rubygems.org/ due to underlying error <Errno::ECONNREFUSED: Failed to open TCP connection to rubygems.org:443 (Connection refused - connect(2) for "rubygems.org" port 443) (https://rubygems.org/specs.4.8.gz)>

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

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

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

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

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

mather

2021/08/18 17:23

現在のGemfileの内容を質問に追記してください。
yoshidesu

2021/08/19 08:06

mather さん ありがとうございます。 gemfile のコード内容を質問本文に添付させて頂きます。
mather

2021/08/19 09:34

現在のGemfileでエラーメッセージは変化しましたか?
yoshidesu

2021/08/19 09:46

sqliteに関するエラーは、無事にgitのファイルをアップデートできたのか、sqliteがdeleteされたらしくエラーが消えました。 後一つ エラーが残っています。 質問文に添付します
guest

回答2

0

ベストアンサー

You are trying to install in deployment mode after changing
your Gemfile. Run bundle install elsewhere and add the
updated Gemfile.lock to version control.

と書かれていますね。

  • Gemfile を更新したら、 bundle install を行って Gemfile.lock を作っておく
  • Gemfile.lock もバージョン管理に含めて、詳細な現在のバージョン情報を確定する

詳細な現在のバージョン情報について、例えば gem "sass-rails", ">= 6" と書かれたときに 6.x.x の部分は指定されていないわけで、 Gemfile.lock には bundle install を実行したときに取得した 6.x.x という具体的なバージョンが記録されます。
この確定したバージョンで動作確認したものをHeroku上でも動作させたいという前提に基づき、 Gemfile.lock を必要としています。

投稿2021/08/19 10:13

mather

総合スコア6753

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

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

yoshidesu

2021/08/19 10:34

matherさん ありがとうございます。 gemfile の内容を更新したら、gemfileにて確定させる必要があり、gemfileが必要とされていることの理論、流れがわかりました。 具体的な手順がわからなかったので、こちらでgemfileを確定させる方法としてbundle install のコマンドを打つことが必要なのだろうと判断し、terminalでbundle installと打ち込むと、質問文に掲載しましたエラーが出てきてしまいました。 具体的な手順等教えて頂ければ、幸いです。 宜しくお願い致します
mather

2021/08/19 10:39

rubygems.org に接続できないエラーはbundlerなどとは無関係かと思います。 確実にインターネットに接続できている状況で、 bundle install を再実行してみてください。 お使いの環境がもしプロキシやVPN、あるいは外部への接続許可が必要であればこちらでは解決できませんん。
siruku6

2021/08/20 01:07

ネットワークの問題のようなので、herokuやrailsの問題ではない可能性があります。 そもそも、もともとbundle installは実行できたのでしょうか? (多分できたのだと思います、その時と全く同じ環境、ネットワーク設定で実行するのが確実かもしれません。) また、ネットワークの問題を解消しようとしている記事も見つけましたが、正直、これが良いのかどうか私には見当もつかないので、試す際は自己責任でお願いいたします。。。 https://stackoverflow.com/questions/36869247/error-installing-ruby-gems
yoshidesu

2021/08/20 06:11

無事にクリアできました!! gemlockのファイルを一度消して、その後に変更したgemfileをもう一度 bundle install しgemlockが出来上がった後にaddしたらエラーが解消されました
guest

0

エラーメッセージに書かれていますが、sqlite3はherokuでは使えません。

少なくとも、私の知る限りでは、postgresqlにする必要があります。

(もしかしたら何か設定を切り替えたり、有料プランにすれば他のDBが使える可能性があるかもしれませんが、それは経験がないので、ご自身で調べていただければと思います。)

matherさんもおっしゃっていますが、Gemfileにまず問題があり、
さらに、config/database.ymlの設定も書き換える必要があります。 ←間違いっぽい


具体的な方法は、以下の記事などが参考になりそうです
HerokuにRailsアプリをデプロイした時のdatabase.ymlの置き換えについて
ただし、動作確認はしていないので、他の似たような記事も検索しつつ、うまくいく方法を探してみましょう。

投稿2021/08/18 20:10

編集2021/08/18 20:15
siruku6

総合スコア1382

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

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

yoshidesu

2021/08/19 08:11

sirukuさんありがとうございます。 記事の通り、database.ymlも書き換えましたが、間違えなのでしょうか。。。 一度元に戻して見ます。 参照で頂いた記事も見て見ます
siruku6

2021/08/20 01:01

おそらく既に解決済みかと存じますが、念のため質問にお返事しておきます。 紹介した記事を読む限り、database.ymlはそもそも書き換えなくて良さそうです。 記事を読んでみてどう感じましたか? database.ymlを書き換える必要がありそうに見えましたか??
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.50%

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

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

質問する

関連した質問