1
2

More than 3 years have passed since last update.

Rails tutorial 第1章 デプロイエラー

Posted at

Railsチュートリアルで初っ端から詰まったのでQiitaの投稿テストも兼ねて解決法をメモ。
最初のデプロイでエラーになるパターンはどうやら多いようで、原因も多岐に渡るよう。
その内のいくつかを試したが上手くいかなかったので、もう一度エラーメッセージを見直した。

remote: 
remote:  !
remote:  !     Could not detect rake tasks
remote:  !     ensure you can run `$ bundle exec rake -P` against your app
remote:  !     and using the production group of your Gemfile.
remote:  !     rake aborted!
remote:  !     LoadError: cannot load such file -- bootsnap/setup
remote:  !     /tmp/build_91342a9bef3f968c6ae2092e716225bc/config/boot.rb:4:in `require'
remote:  !     /tmp/build_91342a9bef3f968c6ae2092e716225bc/config/boot.rb:4:in `<top (required)>'
remote:  !     /tmp/build_91342a9bef3f968c6ae2092e716225bc/config/application.rb:1:in `require_relative'
remote:  !     /tmp/build_91342a9bef3f968c6ae2092e716225bc/config/application.rb:1:in `<top (required)>'
remote:  !     /tmp/build_91342a9bef3f968c6ae2092e716225bc/Rakefile:4:in `require_relative'
remote:  !     /tmp/build_91342a9bef3f968c6ae2092e716225bc/Rakefile:4:in `<top (required)>'
remote:  !     /tmp/build_91342a9bef3f968c6ae2092e716225bc/vendor/bundle/ruby/2.6.0/gems/rake-13.0.0/lib/rake/rake_module.rb:29:in `load'
remote:  !     /tmp/build_91342a9bef3f968c6ae2092e716225bc/vendor/bundle/ruby/2.6.0/gems/rake-13.0.0/lib/rake/rake_module.rb:29:in `load_rakefile'
remote:  !     /tmp/build_91342a9bef3f968c6ae2092e716225bc/vendor/bundle/ruby/2.6.0/gems/rake-13.0.0/lib/rake/application.rb:703:in `raw_load_rakefile'
remote:  !     /tmp/build_91342a9bef3f968c6ae2092e716225bc/vendor/bundle/ruby/2.6.0/gems/rake-13.0.0/lib/rake/application.rb:104:in `block in load_rakefile'
remote:  !     /tmp/build_91342a9bef3f968c6ae2092e716225bc/vendor/bundle/ruby/2.6.0/gems/rake-13.0.0/lib/rake/application.rb:186:in `standard_exception_handling'
remote:  !     /tmp/build_91342a9bef3f968c6ae2092e716225bc/vendor/bundle/ruby/2.6.0/gems/rake-13.0.0/lib/rake/application.rb:103:in `load_rakefile'
remote:  !     /tmp/build_91342a9bef3f968c6ae2092e716225bc/vendor/bundle/ruby/2.6.0/gems/rake-13.0.0/lib/rake/application.rb:82:in `block in run'
remote:  !     /tmp/build_91342a9bef3f968c6ae2092e716225bc/vendor/bundle/ruby/2.6.0/gems/rake-13.0.0/lib/rake/application.rb:186:in `standard_exception_handling'
remote:  !     /tmp/build_91342a9bef3f968c6ae2092e716225bc/vendor/bundle/ruby/2.6.0/gems/rake-13.0.0/lib/rake/application.rb:80:in `run'
remote:  !     /tmp/build_91342a9bef3f968c6ae2092e716225bc/vendor/bundle/ruby/2.6.0/gems/rake-13.0.0/exe/rake:27:in `<top (required)>'
remote:  !     vendor/bundle/bin/rake:29:in `load'
remote:  !     vendor/bundle/bin/rake:29:in `<main>'
remote:  !

どうやら"bootsnap/setup"とやらに原因があるらしい。
appディレクトリから同名のファイルを探すが見つからず。
そこでbootsnapでググるとこちらがヒット。

[bootsnapについて調べてみた](https://qiita.com/Daniel_Nakano/items/aadeaa7ae4e227b73878)

Railsの処理を最適化するGemらしい。
チュートリアルで導入するよう指示されているGem一覧には入っていない。
そこでとりあえずこれを参考記事通りに導入してみる。

Gemfile.rb
gem 'bootsnap', require: false

さらに記事通りにconfig/boot.rbのrequire 'bundler/setup'の直下にrequire 'bootsnap/setup'を追加しようとするが、なぜか元から書いてある。。。
そのままgit pushしてデプロイを試みると、問題なくデプロイ成功。

以下は確認していないので推測になるが、私の環境ではRailsにデフォルトでbootsnapが入っており、これがGemfileの書き換えの際に抜けることでboot.rbのbootsnapに関する記述が取り残されてエラーの原因になったようである。

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