LoginSignup
12
9

More than 3 years have passed since last update.

【herokuへのデプロイ時】bash: rails: command not found のエラー解決方法

Last updated at Posted at 2020-04-18

herokuへのデプロイでタイトルのエラーが発生した為、解決方法を記載させていただきます

環境

MacOS
Rails 5.2.4.1
heroku/7.39.2 darwin-x64 node-v12.13.0

状況

開発環境で、作成したRuby on Railsのアプリケーションを、
herokuにデプロイするために、
①heroku create
②git add .
③git commit -m "コミットメッセージ "
④push heroku ブランチ名
行った。

heroku run rails db:migrate
これで「heroku上でアプリが表示できる!」と期待するも、

$ heroku run rails db:migrate
Running rails db:migrate on ⬢ アプリ名... up, run.1884 (Free)
bash: rails: command not found

bash: rails: command not foundという
エラーが出てしまった。

原因

原因は非常にシンプルで、私がdevelopブランチをherokuにpushしていたことが関係していました。

解決策

master以外のブランチを、herokuにpushする際には、

$ git push heroku 【ブランチ名】 :master

と、最後にmasterをつけてpushする必要がありました。

私の場合は、git push heroku develop:master
で、無事デプロイすることができました。

12
9
0

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
12
9