LoginSignup
0
0

More than 3 years have passed since last update.

Railsチュートリアル備忘録(1章 1.5.1)②

Last updated at Posted at 2020-10-15

環境

macOS Catalina 10.15.5
Rails 6.0.3

Railsチュートリアルとそれに付随するいろいろを書いていきます。
Githubに慣れたいので、チュートリアルは第6版に準拠しています。

1.5.1 Herokuのセットアップとデプロイ

リスト 1.21

$ heroku create

 ›   Warning: heroku update available from 7.42.13 to 7.43.0.
Creating app... done, ⬢ *****
https://*****.herokuapp.com/ | https://git.heroku.com/*****.git

$ git push heroku master

remote:        LoadError: cannot load such file -- uglifier
error: failed to push some refs to 'https://git.heroku.com/*****.git'

下記を参考に、
https://algorithm.joho.info/heroku/error-failed-to-push-some-refs-to/
$ git fetch
$ git rebase heroku/master
を実行したが、下記のようになり解決せず。

fatal: invalid upstream 'heroku/master'

また、下記を参考に、
https://ja.stackoverflow.com/questions/67934/git-push-heroku-master%E3%81%A7%E7%99%BA%E7%94%9F%E3%81%99%E3%82%8B%E3%82%A8%E3%83%A9%E3%83%BC-precompiling-assets-failed-error-failed-to-pu
Gemfile にuglifier のgem追加をしてみる。

Gemfile
gem 'bootsnap',   '1.4.5', require: false
gem 'uglifier'

再度、下記実行
$ git commit -a -m "Update Gemfile for Heroku"
$ git push heroku master

remote: LoadError: cannot load such file -- uglifierは消えたが
error: failed to push some refs to~は変わらず。

$ git push heroku master実行時のエラーに下記があった。

remote: ###### WARNING:
remote: 
remote:        This buildpack was created as a stop-gap measure to allow running applications with Bundler 2 on Heroku.
remote:        Heroku now supports Bundler 2 directly: https://devcenter.heroku.com/changelog-items/1563
remote:        
remote:        Please discontinue use of this buildpack and instead directly use the `heroku/ruby` buildpack.
remote:        
remote:        To remove this buildpack use the `heroku buildpacks` command to list your existing buildpacks.
remote:        
remote:        If you only have one buildpack listed you can run:
remote:        
remote:        ```
remote:        heroku buildpacks:set heroku/ruby
remote:        ```
remote:        
remote:        If you have multiple buildpacks, you'll need to add the buildpack to the correct location using
remote:        `heroku buildpacks:add heroku/ruby -i <correct index>` and then remove this buildpack via:
remote:        
remote:        ```
remote:        heroku buildpacks:remove https://github.com/bundler/heroku-buildpack-bundler2
remote:        ```

$ heroku buildpacksでは下記のBuildpackのみ。

https://github.com/bundler/heroku-buildpack-bundler2

そのため$ heroku buildpacks:set heroku/rubyを実行。

Buildpack set. Next release on pacific-atoll-18588 will use heroku/ruby.
Run git push heroku main to create a new release using this buildpack.

再度$ git push heroku masterすると今度は下記の警告。

remote:        webpack binstubs not found.
remote:        Have you run rails webpacker:install ?
remote:        Make sure the bin directory or binstubs are not included in .gitignore
remote:        Exiting!

https://archive.blog.inomar.me/2018/08/19/rails5-1%E3%81%A7webpack%E3%81%8C%E4%BD%BF%E7%94%A8%E3%81%A7%E3%81%8D%E3%82%8B%E3%81%AE%E3%81%A7vuejs%E3%81%A7%E9%81%8A%E3%82%93%E3%81%A7%E3%81%BF%E3%81%9F/
上記を参考にして$ bundle exec rails webpacker:installを実行。
再度$ git push heroku masterしても上記の警告が消えず。

remote:        webpack binstubs not found.
remote:        Have you run rails webpacker:install ?
remote:        Make sure the bin directory or binstubs are not included in .gitignore
remote:        Exiting!

$ git push heroku mainを実行。

error: src refspec main does not match any
error: failed to push some refs to 'https://git.heroku.com/*****.git'

$ git push heroku main -fで強制プッシュしようとしても同じ結果だったので
gitのリポジトリを削除・再作成し、herokuのアプリも再作成してadd、commit、pushを行ったが、
以下のエラーは消えず…

 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/*****.git'

ダメ元で再度$ git push heroku main -fを実行したところ、ようやく完了。
無意味なダウンロード等を結構してしまったと思うのでこの後無事に動作するのかが不安…

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