LoginSignup
0
1

More than 1 year has passed since last update.

heroku 関連のコマンド集 &Error対応編

Posted at

herokuに新しいアプリケーションを作る

heroku create

アセットプリコンパイルする

rails assets:precompile RAILS_ENV=production

GemfileのRubyのバージョンをコメントアウトする

 source 'https://rubygems.org'
 git_source(:github) { |repo| "https://github.com/#{repo}.git" }
 # ruby '2.6.5'

$ bundle install

コミットする

~/workspace/heroku_test_app (master) $ git add -A
~/workspace/heroku_test_app (master) $ git commit -m "init"

Heroku buildpackを追加する

$ heroku buildpacks:set heroku/ruby
$ heroku buildpacks:add --index 1 heroku/nodejs

herokuにデプロイ

git push heroku master

デプロイに失敗する場合

$ heroku stack:set heroku-18

現在使われているstackを確認したい場合

heroku stack

エラー出てstack下げたら再度デプロイ

こんなエラーが出たら
b25617bdae030baecf628262e7658361.png

Gemfile.lockを削除

rm Gemfile.lock

バージョン2.2.11のbundlerをインストール

 gem install bundler -v 2.2.11

バージョン2.2.11のbundlerをインストールできているか確認

bundle exec bundle -v
Bundler version 2.2.11

上記のように、2.2.11が表示されればok

バージョン2.2.11のbundlerを用いて、再度gemをインストールする

 bundler _2.2.11_ install

再度コミットしたのち、Herokuにpushする

$ git add -A
$ git commit -m "bundlerのバージョンを2.2.11に変更"
$ git push heroku master

Error関連

Bundler Output: Unable to find a spec satisfying nokogiri (>= 1.6) in the set. Perhaps the
   lockfile is corrupted? Found nokogiri (1.11.2-x86_64-darwin), nokogiri
   (1.11.2-x86_64-darwin), nokogiri (1.11.2-x86_64-darwin) that did not match the
   current platform.
$ bundle lock --add-platform x86_64-linux
$ git add -A
$ git commit -m 'Add platform'
$ git push heroku master

ブランチ分けた所からherokuをアップデート

git push heroku ブランチ名:master

シードデータをherokuに反映

heroku run rake db:seed

herokuのデータベースを綺麗にする

heroku PG:reset DATABACE

herokuのmigrationを更新

heroku run rails db:migrate

アプリ名確認

heroku config

一連の流れは大体こんな感じのコマンドを使えば
ある程度は対応できるであろうの記事でした!!!!

0
1
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
0
1