akatuki2121332
@akatuki2121332 (ビノ)

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

railsでherokuにデプロイするときにエラーが発生します。

railsでherokuにデプロイするときにエラーが発生します。

発生している問題・エラー

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

git push heroku masterを実行したときの全文

$ git push heroku master
Enumerating objects: 108, done.
Counting objects: 100% (108/108), done.
Delta compression using up to 8 threads
Compressing objects: 100% (90/90), done.
Writing objects: 100% (108/108), 152.62 KiB | 7.27 MiB/s, done.
Total 108 (delta 6), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-18 stack
remote: -----> Determining which buildpack to use for this app
remote:  !     Warning: Multiple default buildpacks reported the ability to handle this app. The first buildpack in the list below will be used.
remote:                         Detected buildpacks: Ruby,Node.js
remote:                         See https://devcenter.heroku.com/articles/buildpacks#buildpack-detect-order
remote: -----> Ruby app detected
remote: -----> Installing bundler 2.3.10
remote: -----> Removing BUNDLED WITH version in the Gemfile.lock
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-3.1.2
remote: -----> Installing dependencies using bundler 2.3.10
remote:        Running: BUNDLE_WITHOUT='development:test' BUNDLE_PATH=vendor/bundle BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 bundle install -j4
remote:        Fetching gem metadata from https://rubygems.org/..........
remote:        Fetching rake 12.3.3
remote:        Installing rake 12.3.3
remote:        Fetching concurrent-ruby 1.1.10
remote:        Fetching minitest 5.16.2
remote:        Fetching zeitwerk 2.6.0
remote:        Fetching thread_safe 0.3.6
remote:        Installing minitest 5.16.2
remote:        Installing zeitwerk 2.6.0
remote:        Fetching builder 3.2.4
remote:        Installing concurrent-ruby 1.1.10
remote:        Installing thread_safe 0.3.6
remote:        Fetching erubi 1.10.0
remote:        Installing erubi 1.10.0
remote:        Installing builder 3.2.4
remote:        Fetching mini_portile2 2.8.0
remote:        Using racc 1.6.0
remote:        Installing mini_portile2 2.8.0
remote:        Fetching crass 1.0.6
remote:        Fetching rack 2.2.4
remote:        Installing crass 1.0.6
remote:        Fetching nio4r 2.5.8
remote:        Fetching websocket-extensions 0.1.5
remote:        Installing rack 2.2.4
remote:        Installing websocket-extensions 0.1.5
remote:        Fetching marcel 1.0.2
remote:        Fetching mini_mime 1.1.2
remote:        Installing nio4r 2.5.8 with native extensions
remote:        Installing marcel 1.0.2
remote:        Fetching msgpack 1.5.4
remote:        Installing mini_mime 1.1.2
remote:        Installing msgpack 1.5.4 with native extensions
remote:        Using bundler 2.3.10
remote:        Fetching ffi 1.15.5
remote:        Fetching method_source 1.0.0
remote:        Installing method_source 1.0.0
remote:        Fetching pg 1.1.4
remote:        Installing pg 1.1.4 with native extensions
remote:        Installing ffi 1.15.5 with native extensions
remote:        Fetching thor 1.2.1
remote:        Installing thor 1.2.1
remote:        Fetching rb-fsevent 0.11.1
remote:        Installing rb-fsevent 0.11.1
remote:        Fetching tilt 2.0.11
remote:        Installing tilt 2.0.11
remote:        Fetching turbolinks-source 5.2.0
remote:        Installing turbolinks-source 5.2.0
remote:        Fetching nokogiri 1.13.8 (x86_64-linux)
remote:        Installing nokogiri 1.13.8 (x86_64-linux)
remote:        Fetching tzinfo 1.2.10
remote:        Installing tzinfo 1.2.10
remote:        Fetching i18n 1.12.0
remote:        Installing i18n 1.12.0
remote:        Fetching websocket-driver 0.7.5
remote:        Installing websocket-driver 0.7.5 with native extensions
remote:        Fetching mail 2.7.1
remote:        Installing mail 2.7.1
remote:        Fetching rack-test 2.0.2
remote:        Installing rack-test 2.0.2
remote:        Fetching rack-proxy 0.7.2
remote:        Installing rack-proxy 0.7.2
remote:        Fetching sprockets 3.7.2
remote:        Installing sprockets 3.7.2
remote:        Fetching puma 4.3.6
remote:        Installing puma 4.3.6 with native extensions
remote:        Fetching turbolinks 5.2.0
remote:        Installing turbolinks 5.2.0
remote:        Fetching loofah 2.18.0
remote:        Installing loofah 2.18.0
remote:        Fetching activesupport 6.0.4
remote:        Installing activesupport 6.0.4
remote:        Fetching bootsnap 1.10.3
remote:        Installing bootsnap 1.10.3 with native extensions
remote:        Fetching rails-html-sanitizer 1.4.3
remote:        Installing rails-html-sanitizer 1.4.3
remote:        Fetching rails-dom-testing 2.0.3
remote:        Installing rails-dom-testing 2.0.3
remote:        Fetching globalid 1.0.0
remote:        Installing globalid 1.0.0
remote:        Fetching activemodel 6.0.4
remote:        Installing activemodel 6.0.4
remote:        Fetching jbuilder 2.9.1
remote:        Installing jbuilder 2.9.1
remote:        Fetching actionview 6.0.4
remote:        Installing actionview 6.0.4
remote:        Fetching activejob 6.0.4
remote:        Installing activejob 6.0.4
remote:        Fetching activerecord 6.0.4
remote:        Installing activerecord 6.0.4
remote:        Fetching actionpack 6.0.4
remote:        Installing actionpack 6.0.4
remote:        Fetching actioncable 6.0.4
remote:        Installing actioncable 6.0.4
remote:        Fetching activestorage 6.0.4
remote:        Installing activestorage 6.0.4
remote:        Fetching actionmailer 6.0.4
remote:        Installing actionmailer 6.0.4
remote:        Fetching railties 6.0.4
remote:        Installing railties 6.0.4
remote:        Fetching sprockets-rails 3.4.2
remote:        Installing sprockets-rails 3.4.2
remote:        Fetching actionmailbox 6.0.4
remote:        Installing actionmailbox 6.0.4
remote:        Fetching actiontext 6.0.4
remote:        Installing actiontext 6.0.4
remote:        Fetching webpacker 4.0.7
remote:        Installing webpacker 4.0.7
remote:        Fetching rails 6.0.4
remote:        Installing rails 6.0.4
remote:        Fetching rb-inotify 0.10.1
remote:        Installing rb-inotify 0.10.1
remote:        Fetching sass-listen 4.0.0
remote:        Installing sass-listen 4.0.0
remote:        Fetching sass 3.7.4
remote:        Installing sass 3.7.4
remote:        Fetching sass-rails 5.1.0
remote:        Installing sass-rails 5.1.0
remote:        Bundle complete! 18 Gemfile dependencies, 59 gems now installed.
remote:        Gems in the groups 'development' and 'test' were not installed.
remote:        Bundled gems are installed into `./vendor/bundle`
remote:        Post-install message from sass:
remote:
remote:        Ruby Sass has reached end-of-life and should no longer be used.
remote:
remote:        * If you use Sass as a command-line tool, we recommend using Dart Sass, the new
remote:          primary implementation: https://sass-lang.com/install
remote:
remote:        * If you use Sass as a plug-in for a Ruby web framework, we recommend using the
remote:          sassc gem: https://github.com/sass/sassc-ruby#readme
remote:
remote:        * For more details, please refer to the Sass blog:
remote:          https://sass-lang.com/blog/posts/7828841
remote:
remote:        Bundle completed (20.22s)
remote:        Cleaning up the bundler cache.
remote: -----> Installing node-v16.13.1-linux-x64
remote: -----> Installing yarn-v1.22.17
remote: -----> Detecting rake tasks
remote: -----> Preparing app for Rails asset pipeline
remote:        Running: rake assets:precompile
remote:        Rails couldn't infer whether you are using multiple databases from your database.yml and can't generate the tasks for the non-primary databases. If you'd like to use this feature, please simplify your ERB.
remote:        rake aborted!
remote:        Psych::BadAlias: Unknown alias: default
remote:        /tmp/build_e753bcaf/vendor/bundle/ruby/3.1.0/gems/webpacker-4.0.7/lib/webpacker/env.rb:30:in `available_environments'
remote:        /tmp/build_e753bcaf/vendor/bundle/ruby/3.1.0/gems/webpacker-4.0.7/lib/webpacker/env.rb:21:in `current'
remote:        /tmp/build_e753bcaf/vendor/bundle/ruby/3.1.0/gems/webpacker-4.0.7/lib/webpacker/env.rb:15:in `inquire'
remote:        /tmp/build_e753bcaf/vendor/bundle/ruby/3.1.0/gems/webpacker-4.0.7/lib/webpacker/env.rb:7:in `inquire'
remote:        /tmp/build_e753bcaf/vendor/bundle/ruby/3.1.0/gems/webpacker-4.0.7/lib/webpacker/instance.rb:11:in `env'
remote:        /tmp/build_e753bcaf/vendor/bundle/ruby/3.1.0/gems/webpacker-4.0.7/lib/webpacker/instance.rb:18:in `config'
remote:        /tmp/build_e753bcaf/vendor/bundle/ruby/3.1.0/gems/webpacker-4.0.7/lib/webpacker.rb:26:in `config'
remote:        /tmp/build_e753bcaf/vendor/bundle/ruby/3.1.0/gems/webpacker-4.0.7/lib/webpacker/railtie.rb:32:in `block in <class:Engine>'
remote:        /tmp/build_e753bcaf/vendor/bundle/ruby/3.1.0/gems/railties-6.0.4/lib/rails/initializable.rb:32:in `instance_exec'
remote:        /tmp/build_e753bcaf/vendor/bundle/ruby/3.1.0/gems/railties-6.0.4/lib/rails/initializable.rb:32:in `run'
remote:        /tmp/build_e753bcaf/vendor/bundle/ruby/3.1.0/gems/railties-6.0.4/lib/rails/initializable.rb:61:in `block in run_initializers'
remote:        /tmp/build_e753bcaf/vendor/bundle/ruby/3.1.0/gems/railties-6.0.4/lib/rails/initializable.rb:60:in `run_initializers'
remote:        /tmp/build_e753bcaf/vendor/bundle/ruby/3.1.0/gems/railties-6.0.4/lib/rails/application.rb:363:in `initialize!'
remote:        /tmp/build_e753bcaf/config/environment.rb:5:in `<main>'
remote:        /tmp/build_e753bcaf/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
remote:        /tmp/build_e753bcaf/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
remote:        /tmp/build_e753bcaf/vendor/bundle/ruby/3.1.0/gems/zeitwerk-2.6.0/lib/zeitwerk/kernel.rb:35:in `require'
remote:        /tmp/build_e753bcaf/vendor/bundle/ruby/3.1.0/gems/activesupport-6.0.4/lib/active_support/dependencies.rb:324:in `block in require'
remote:        /tmp/build_e753bcaf/vendor/bundle/ruby/3.1.0/gems/activesupport-6.0.4/lib/active_support/dependencies.rb:291:in `load_dependency'
remote:        /tmp/build_e753bcaf/vendor/bundle/ruby/3.1.0/gems/activesupport-6.0.4/lib/active_support/dependencies.rb:324:in `require'
remote:        /tmp/build_e753bcaf/vendor/bundle/ruby/3.1.0/gems/railties-6.0.4/lib/rails/application.rb:339:in `require_environment!'
remote:        /tmp/build_e753bcaf/vendor/bundle/ruby/3.1.0/gems/railties-6.0.4/lib/rails/application.rb:523:in `block in run_tasks_blocks'
remote:        /tmp/build_e753bcaf/vendor/bundle/ruby/3.1.0/gems/sprockets-rails-3.4.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
remote:  !
remote:  ! ## Warning - The same version of this code has already been built: 5061c214488d032582c16164f4fef598ae209e34
remote:  !
remote:  ! We have detected that you have triggered a build from source code with version 5061c214488d032582c16164f4fef598ae209e34
remote:  ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote:  !
remote:  ! If you are developing on a branch and deploying via git you must run:
remote:  !
remote:  !     git push heroku <branchname>:main
remote:  !
remote:  ! This article goes into details on the behavior:
remote:  !   https://devcenter.heroku.com/articles/duplicate-build-version
remote:
remote: Verifying deploy...
remote:
remote: !       Push rejected to stark-badlands-70704.
remote:
To https://git.heroku.com/stark-badlands-70704.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/stark-badlands-70704.git'

環境

wslのubuntuで開発しています。
Rails: 6.0.4
ruby: 2.7.6
Rubygems: ​3.1.6
bundler: 2.1.4
heroku/7.60.2 linux-x64 node-v14.19.0
heroku -18

どうかご教示お願いいたします。

0

1Answer

remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-3.1.2

Heroku では Ruby 3.1.2 が使われていますが、 Rails 6.0 と Ruby 3.1 に互換性がないせいでエラーになっています。

Gemfile に ruby "2.7.6" と書いて Heroku の Ruby を 2.7.6 に指定すれば解決します。

1Like

Comments

  1. @akatuki2121332

    Questioner

    ありがとうございます!
    無事にデプロイできました。

Your answer might help someone💌