HerokuにデプロイしようとしたらArgumentErrorが発生しました。
解決したいこと
Railsチュートリアルで学習中です。バージョンはRuby2.6.9、Rails5.1.6です。
git push heroku master
を実行したら、以下のエラーが発生しました。
ArgumentErrorなので引数が必要以上に与えられているということだと思うのですが、
ググっても同じようなエラーが見つからなかったので、質問しています。
発生している問題・エラー
remote: -----> Installing node-v16.13.1-linux-x64
remote: -----> Detecting rake tasks
remote: -----> Preparing app for Rails asset pipeline
remote: Running: rake assets:precompile
remote: rake aborted!
remote: ArgumentError: wrong number of arguments (given 3, expected 2)
remote: /tmp/build_f70d523e/vendor/bundle/ruby/3.0.0/gems/actionpack-5.1.6/lib/action_dispatch/middleware/static.rb:109:in `initialize'
remote: /tmp/build_f70d523e/vendor/bundle/ruby/3.0.0/gems/actionpack-5.1.6/lib/action_dispatch/middleware/stack.rb:35:in `new'
remote: /tmp/build_f70d523e/vendor/bundle/ruby/3.0.0/gems/actionpack-5.1.6/lib/action_dispatch/middleware/stack.rb:35:in `build'
remote: /tmp/build_f70d523e/vendor/bundle/ruby/3.0.0/gems/actionpack-5.1.6/lib/action_dispatch/middleware/stack.rb:99:in `block in build'
remote: /tmp/build_f70d523e/vendor/bundle/ruby/3.0.0/gems/actionpack-5.1.6/lib/action_dispatch/middleware/stack.rb:99:in `each'
remote: /tmp/build_f70d523e/vendor/bundle/ruby/3.0.0/gems/actionpack-5.1.6/lib/action_dispatch/middleware/stack.rb:99:in `inject'
remote: /tmp/build_f70d523e/vendor/bundle/ruby/3.0.0/gems/actionpack-5.1.6/lib/action_dispatch/middleware/stack.rb:99:in `build'
remote: /tmp/build_f70d523e/vendor/bundle/ruby/3.0.0/gems/railties-5.1.6/lib/rails/engine.rb:508:in `block in app'
remote: /tmp/build_f70d523e/vendor/bundle/ruby/3.0.0/gems/railties-5.1.6/lib/rails/engine.rb:504:in `synchronize'
remote: /tmp/build_f70d523e/vendor/bundle/ruby/3.0.0/gems/railties-5.1.6/lib/rails/engine.rb:504:in `app'
remote: /tmp/build_f70d523e/vendor/bundle/ruby/3.0.0/gems/railties-5.1.6/lib/rails/application/finisher.rb:45:in `block in <module:Finisher>'
remote: /tmp/build_f70d523e/vendor/bundle/ruby/3.0.0/gems/railties-5.1.6/lib/rails/initializable.rb:30:in `instance_exec'
remote: /tmp/build_f70d523e/vendor/bundle/ruby/3.0.0/gems/railties-5.1.6/lib/rails/initializable.rb:30:in `run'
remote: /tmp/build_f70d523e/vendor/bundle/ruby/3.0.0/gems/railties-5.1.6/lib/rails/initializable.rb:59:in `block in run_initializers'
remote: /tmp/build_f70d523e/vendor/bundle/ruby/3.0.0/gems/railties-5.1.6/lib/rails/initializable.rb:58:in `run_initializers'
remote: /tmp/build_f70d523e/vendor/bundle/ruby/3.0.0/gems/railties-5.1.6/lib/rails/application.rb:353:in `initialize!'
remote: /tmp/build_f70d523e/config/environment.rb:5:in `<top (required)>'
remote: /tmp/build_f70d523e/vendor/bundle/ruby/3.0.0/gems/railties-5.1.6/lib/rails/application.rb:329:in `require'
remote: /tmp/build_f70d523e/vendor/bundle/ruby/3.0.0/gems/railties-5.1.6/lib/rails/application.rb:329:in `require_environment!'
remote: /tmp/build_f70d523e/vendor/bundle/ruby/3.0.0/gems/railties-5.1.6/lib/rails/application.rb:445:in `block in run_tasks_blocks'
remote: /tmp/build_f70d523e/vendor/bundle/ruby/3.0.0/gems/sprockets-rails-3.2.2/lib/sprockets/rails/task.rb:61:in `block (2 levels) in define'
remote: Tasks: TOP => environment
remote: (See full trace by running task with --trace)
remote:
remote: !
remote: ! Precompiling assets failed.
remote: !
remote: ! Push rejected, failed to compile Ruby app.
remote:
remote: ! Push failed
自分で試したこと
調べるとsassのバージョンが6以上必要があるようだったので、Gemfileを書き換えました。
- gem 'sass-rails', '5.0.6'
+ gem "sass-rails", "~> 6"
似たようなエラーでconfig/environments/production.rbのこの部分を変更するというのがあったので、変更しました。
- config.assets.js_compressor = :uglifier
+ config.assets.js_compressor = Uglifier.new(harmony: true)