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

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

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

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

Heroku

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

データベース

データベースとは、データの集合体を指します。また、そのデータの集合体の共用を可能にするシステムの意味を含めます

Q&A

解決済

2回答

1680閲覧

Herokuのデプロイに成功したが、heroku run rails db:migrateできない

ikutyan46

総合スコア18

Ruby on Rails 5

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

Heroku

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

データベース

データベースとは、データの集合体を指します。また、そのデータの集合体の共用を可能にするシステムの意味を含めます

0グッド

0クリップ

投稿2020/06/22 14:10

編集2020/06/23 02:25

#実現したいこと
Herokuへのデプロイが成功したので、heroku run rails db:migrateしてアプリが見れる状態にしたい(ログは heroku logs --tailで確認しました)

#環境

  • Rails:5.2.4
  • DB:Postgres

#試したこと

buildpackを実装して、無事にgit push heroku masterして
すると、remote rejectedの状態がなくなり、無事に$ git push heroku master
して、デプロイに成功しました。

成功した時のコード

remote: Verifying deploy... done. To https://git.heroku.com/test-ttmanager.git * [new branch] master -> master

しかし、いざ、run heroku db:migrateすると、下記に示すエラー内容が出てしまいました。こちらの原因と、どうしたら解消できるか、調査中ですが、おわかりの方がいらっしゃれば、ご教示いただけないでしょうか?何卒よろしくお願い致します。

#エラー内容

terminal

1user$ heroku run rails db:migrate 2Running rails db:migrate on ⬢ test-ttmanager... up, run.3315 (Free) 3Usage: 4 rails new APP_PATH [options] 5 6Options: 7 [--skip-namespace], [--no-skip-namespace] # Skip namespace (affects only isolated applications) 8 -r, [--ruby=PATH] # Path to the Ruby binary of your choice 9 # Default: /app/vendor/ruby-2.6.5/bin/ruby 10 -m, [--template=TEMPLATE] # Path to some application template (can be a filesystem path or URL) 11 -d, [--database=DATABASE] # Preconfigure for selected database (options: mysql/postgresql/sqlite3/oracle/frontbase/ibm_db/sqlserver/jdbcmysql/jdbcsqlite3/jdbcpostgresql/jdbc) 12 # Default: sqlite3 13 [--skip-yarn], [--no-skip-yarn] # Don't use Yarn for managing JavaScript dependencies 14 [--skip-gemfile], [--no-skip-gemfile] # Don't create a Gemfile 15 -G, [--skip-git], [--no-skip-git] # Skip .gitignore file 16 [--skip-keeps], [--no-skip-keeps] # Skip source control .keep files 17 -M, [--skip-action-mailer], [--no-skip-action-mailer] # Skip Action Mailer files 18 -O, [--skip-active-record], [--no-skip-active-record] # Skip Active Record files 19 [--skip-active-storage], [--no-skip-active-storage] # Skip Active Storage files 20 -P, [--skip-puma], [--no-skip-puma] # Skip Puma related files 21 -C, [--skip-action-cable], [--no-skip-action-cable] # Skip Action Cable files 22 -S, [--skip-sprockets], [--no-skip-sprockets] # Skip Sprockets files 23 [--skip-spring], [--no-skip-spring] # Don't install Spring application preloader 24 [--skip-listen], [--no-skip-listen] # Don't generate configuration that depends on the listen gem 25 [--skip-coffee], [--no-skip-coffee] # Don't use CoffeeScript 26 -J, [--skip-javascript], [--no-skip-javascript] # Skip JavaScript files 27 [--skip-turbolinks], [--no-skip-turbolinks] # Skip turbolinks gem 28 -T, [--skip-test], [--no-skip-test] # Skip test files 29 [--skip-system-test], [--no-skip-system-test] # Skip system test files 30 [--skip-bootsnap], [--no-skip-bootsnap] # Skip bootsnap gem 31 [--dev], [--no-dev] # Setup the application with Gemfile pointing to your Rails checkout 32 [--edge], [--no-edge] # Setup the application with Gemfile pointing to Rails repository 33 [--rc=RC] # Path to file containing extra configuration options for rails command 34 [--no-rc], [--no-no-rc] # Skip loading of extra configuration options from .railsrc file 35 [--api], [--no-api] # Preconfigure smaller stack for API only apps 36 -B, [--skip-bundle], [--no-skip-bundle] # Don't run bundle install 37 [--webpack=WEBPACK] # Preconfigure for app-like JavaScript with Webpack (options: react/vue/angular/elm/stimulus) 38 39Runtime options: 40 -f, [--force] # Overwrite files that already exist 41 -p, [--pretend], [--no-pretend] # Run but do not make any changes 42 -q, [--quiet], [--no-quiet] # Suppress status output 43 -s, [--skip], [--no-skip] # Skip files that already exist 44 45Rails options: 46 -h, [--help], [--no-help] # Show this help message and quit 47 -v, [--version], [--no-version] # Show Rails version number and quit 48 49Description: 50 The 'rails new' command creates a new Rails application with a default 51 directory structure and configuration at the path you specify. 52 53 You can specify extra command-line arguments to be used every time 54 'rails new' runs in the .railsrc configuration file in your home directory. 55 56 Note that the arguments specified in the .railsrc file don't affect the 57 defaults values shown above in this help message. 58 59Example: 60 rails new ~/Code/Ruby/weblog 61 62 This generates a skeletal Rails installation in ~/Code/Ruby/weblog.

log

12020-06-22T13:31:49.000000+00:00 app[api]: Build started by user ※※*@※※*.com 22020-06-22T13:35:47.312574+00:00 app[api]: Set LANG, RACK_ENV, RAILS_ENV, RAILS_LOG_TO_STDOUT, RAILS_SERVE_STATIC_FILES, SECRET_KEY_BASE config vars by user ※※*@※※*.com 32020-06-22T13:35:47.312574+00:00 app[api]: Release v3 created by user saito.k.13184@gmail.com 42020-06-22T13:35:50.833684+00:00 app[api]: Attach DATABASE (@ref:postgresql-opaque-77523) by user ※※*@※※*.com 52020-06-22T13:35:50.833684+00:00 app[api]: Running release v4 commands by user ※※*@※※*.com 62020-06-22T13:35:50.852147+00:00 app[api]: @ref:postgresql-opaque-77523 completed provisioning, setting DATABASE_URL. by user ※※*@※※*.com 72020-06-22T13:35:50.852147+00:00 app[api]: Release v5 created by user ※※*@※※*.com 82020-06-22T13:35:51.213419+00:00 app[api]: Release v6 created by user ※※*@※※*.com 92020-06-22T13:35:51.213419+00:00 app[api]: Deploy 2e260b4a by user ※※*@※※*.com 102020-06-22T13:35:51.231802+00:00 app[api]: Scaled to console@0:Free rake@0:Free web@1:Free by user ※※*@※※*.com 112020-06-22T13:35:57.345087+00:00 heroku[web.1]: Starting process with command `bin/rails server -p ${PORT:-5000} -e production` 122020-06-22T13:35:58.000000+00:00 app[api]: Build succeeded 132020-06-22T13:36:00.307868+00:00 app[web.1]: bash: bin/rails: No such file or directory 142020-06-22T13:36:00.405471+00:00 heroku[web.1]: Process exited with status 127 152020-06-22T13:36:00.462719+00:00 heroku[web.1]: State changed from starting to crashed 162020-06-22T13:36:00.464965+00:00 heroku[web.1]: State changed from crashed to starting 172020-06-22T13:36:06.747661+00:00 heroku[web.1]: Starting process with command `bin/rails server -p ${PORT:-5000} -e production` 182020-06-22T13:36:10.116015+00:00 app[web.1]: bash: bin/rails: No such file or directory 192020-06-22T13:36:10.201753+00:00 heroku[web.1]: Process exited with status 127 202020-06-22T13:36:10.265126+00:00 heroku[web.1]: State changed from starting to crashed 212020-06-22T13:38:41.197685+00:00 app[api]: Starting process with command `rails db:migrate` by user ※※*@※※*.com 222020-06-22T13:38:45.443569+00:00 heroku[run.3315]: State changed from starting to up 232020-06-22T13:38:45.503484+00:00 heroku[run.3315]: Awaiting client 242020-06-22T13:38:45.528062+00:00 heroku[run.3315]: Starting process with command `rails db:migrate` 252020-06-22T13:38:49.972027+00:00 heroku[run.3315]: Process exited with status 0 262020-06-22T13:38:50.000563+00:00 heroku[run.3315]: State changed from up to complete 272020-06-22T13:44:37.381050+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=test-ttmanager.herokuapp.com request_id=※※※*-※※※* fwd="103.5.140.170" dyno= connect= service= status=503 bytes= protocol=https 282020-06-22T13:44:37.729897+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=test-ttmanager.herokuapp.com request_id=01fffd4e-ec3d-478f-84a3-add40e566298 fwd="※*.※*.※*.170" dyno= connect= service= status=※* bytes= protocol=https

#追記 回答を受けて、試したこと

deployしたdirにcdしていないようにみえます。

Gemfilや app, config, public, db などのあるdirにcdする操作をその前に行ってください

とあったので、ルートディレクトリから対象のdirに移動して色々試しましたが、結果うまくいきませんでした。何がいけなかったのか?どうしたらいいのか、ご教示頂けますと幸いです。

①対象dirに移動
②念のためheroku appsで確認したが、ちゃんと入っている

== **@**.com Apps App 1 App 2 App 3

③移動したdirに、リモートリポジトリ が存在するか確認

***:***(アプリ名) user$ git remote -v heroku https://git.heroku.com/(アプリ名).git (fetch) heroku https://git.heroku.com/(アプリ名).git (push)

④公式ガイドを元に、再度デプロイし、heroku run db:migrateするが、失敗。

****:(アプリ名) user$ heroku login heroku: Press any key to open up the browser to login or q to exit: Opening browser to https://cli-auth.heroku.com/auth/cli/browser/****-****-****-****-******** Logging in... done Logged in as ****@***.com ****:(アプリ名) user$ heroku git:clone -a (アプリ名) Cloning into '(アプリ名)'... remote: Counting objects: 707, done. remote: Compressing objects: 100% (302/302), done. remote: Total 707 (delta 364), reused 707 (delta 364) Receiving objects: 100% (707/707), 238.07 KiB | 354.00 KiB/s, done. Resolving deltas: 100% (364/364), done. ****:(アプリ名) user$ cd test-ttmanager ****:(アプリ名) user$ git add . ****:(アプリ名) user$ git commit -am "make it better" On branch master Your branch is up to date with 'heroku/master'. nothing to commit, working tree clean ****:(アプリ名) user$ git push heroku master Everything up-to-date ****:(アプリ名) user$ heroku run rails db:migrate Running rails db:migrate on ⬢ test-ttmanager... up, run.7994 (Free) Usage: rails new APP_PATH [options] (以下、質問当初と同じエラー)

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

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

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

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

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

guest

回答2

0

ベストアンサー

前回の質問でも回答したのですが、同じ回答を記載しておきます。
https://qiita.com/arekore0/items/eae550bdbcc78eeac082#%E3%81%A9%E3%81%86%E3%82%84%E3%82%89

Gitのリポジトリを再度作り直して、上記のように適切なディレクトリでgit push origin masterする必要があるかと思います。

投稿2020/06/23 22:57

no1knows

総合スコア3365

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

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

ikutyan46

2020/06/24 01:55

no1konwsさん ご回答ありがとうございます。再度リモートリポジトリを作成し直したところ別の問題が発生しましたので、この質問については終了とします。 お時間頂きありがとうございました!
guest

0

deployしたdirにcdしていないようにみえます。
Gemfilや app, config, public, db などのあるdirにcdする操作をその前に行ってください

投稿2020/06/22 22:55

winterboum

総合スコア23401

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

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

ikutyan46

2020/06/23 02:01

winterboumさん ご回答ありがとうございます。ルートディレクトリに、heroku run rails db:migrateを試みていたので、Gemfilや app, config, public, dbなどのあるアプリのdirに移動して、heroku run rails db:migrateしたのですが、結果が質問と同じで、変わりませんでした。 その後、色々試しましたので、後ほど質問を編集致します。今一度ご確認頂けますと幸いです。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.46%

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

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

質問する

関連した質問