RailsアプリをHerokuに再デプロイできない(失敗談)

今回は、Herokuにデプロイ済のRailsアプリ(Railsチュートリアル)を再デプロイしようとしてるんですけど、諸々のエラーで再デプロイできない・・という内容になります。

経緯としては、Herokuにデプロイ済のRailsアプリ(Railsチュートリアル)を放置しており、久しぶりに表示して見たら、エラーになってたので、それを直そうとしてるということです。

原因は、今のスタックが廃止になるので、アップグレードしろ・・とのことでした。

なので、とりあえずIDEとして、AWSのCloud Shellで(なんでCloud9は廃止になってしまったのか?)、デプロイ済のソースコードを引っ張ってきて、空のコミットを行い、git push heroku masterでデプロイしようとしたのですが、以下のエラーが発生しました。

The Ruby version you are trying to install does not exist on this stack…

インストールしようとしているRubyのバージョンが、このスタックには無い・・とのことでした。

で、Rubyをアップデートし、gemfileにそのバージョンのrubyを記載したのですが(ruby “3.2.2”)、bundle installとbundle updateで以下のエラーが出ました。

[cloudshell-user@ip-10-130-63-103 ogawas]$ bundle update
Fetching gem metadata from https://rubygems.org/……..
Resolving dependencies…
Could not find compatible versions

Because listen >= 3.1.3, < 3.2.0 depends on Ruby >= 2.2.3, < 3.A and Gemfile depends on listen = 3.1.5, Ruby >= 2.2.3, < 3.A is required.
So, because current Ruby version is = 3.2.2,
version solving has failed.

なので、gem listen 3.1.5→3.4.1に変更し、bundle updateすると以下のエラーが発生。
An error occurred while installing rake (13.2.1), and Bundler cannot continue

An error occurred while installing rake (13.2.1), and Bundler cannot continue.

In Gemfile:
coffee-rails was resolved to 4.2.2, which depends on
railties was resolved to 5.1.6, which depends on
rake

なので、まずはrakeをインストールしましたが、この後は、RubyGemが足りないので、インストール・・足りないので、インストールを何回か繰り返しました。

そして、再度、bundle installやupdateをしたら・・

Unfortunately, an unexpected error occurred, and Bundler cannot continue.

First, try this link to see if there are any existing issue reports for this error:
https://github.com/rubygems/rubygems/search?q=cannot+load+such+file+–+psych%2Fsyntax_error&type=Issues

If there aren’t any reports for this error yet, please fill in the new issue form located at https://github.com/rubygems/rubygems/issues/new?labels=Bundler&template=bundler-related-issue.md, and copy and paste the report template above in there.

ちょっと意味が分からず、とりあえず、git push heroku masterでデプロイしようとしたのですが、以下のエラーが発生しました。

remote: Updated 18760 paths from 4b2a6ff6
remote: Compressing source files… done.
remote: Building source:
remote:
remote: —–> Building on the Heroku-24 stack
remote: —–> Using buildpack: heroku/ruby
remote: —–> Ruby app detected
remote: —–> Installing bundler 1.17.3
remote: —–> Removing BUNDLED WITH version in the Gemfile.lock
remote: —–> Compiling Ruby/Rails
remote: —–> Using Ruby version: ruby-3.2.2
remote: Purging Cache. Changing stack from heroku-18 to heroku-24
remote: —–> Installing dependencies using bundler 1.17.3
remote: Running: BUNDLE_WITHOUT=’development:test’ BUNDLE_PATH=vendor/bundle BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 BUNDLE_GLOBAL_PATH_APPENDS_RUBY_SCOPE=1 bundle install -j4
remote: You are trying to install in deployment mode after changing
remote: your Gemfile. Run bundle install elsewhere and add the
remote: updated Gemfile.lock to version control.
remote:
remote: Bundler is unlocking ruby
remote:
remote: You have added to the Gemfile:
remote: * listen (= 3.4.1)
remote:
remote: You have deleted from the Gemfile:
remote: * listen (= 3.1.5)
remote: Bundler Output: You are trying to install in deployment mode after changing
remote: your Gemfile. Run bundle install elsewhere and add the
remote: updated Gemfile.lock to version control.
remote:
remote: Bundler is unlocking ruby
remote:
remote: You have added to the Gemfile:
remote: * listen (= 3.4.1)
remote:
remote: You have deleted from the Gemfile:
remote: * listen (= 3.1.5)
remote:
remote: !
remote: ! Failed to install gems via Bundler.
remote: !
remote: ! Push rejected, failed to compile Ruby app.
remote:
remote: ! Push failed
remote: Verifying deploy…
remote:
remote: ! Push rejected to ogawas.
remote:
To https://git.heroku.com/ogawas.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to ‘https://git.heroku.com/ogawas.git’

ちょっと頭が混乱してきたのですが、バージョン関係のエラー(Gemfile.lock内の依存性が合わない?)ということは分かりました。

gemfile.lockを削除後、gem install bundler -v 1.17.3でインストールするといいと書かれている記事がありましたが、これをやってもだめでした。

ちょっと今の私には手に負えないですね。Rubyistじゃないので、もう少し調べて知見を得ないとダメです・・

はい。ということで、今後調べて解決していきたいと思いますが、Rubyに詳しい方とか分かる方いらしたら、アドバイスをいただければ幸いです。

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

CAPTCHA