LoginSignup
4
2

HerokuデプロイでHost key verification failed.が出た時の解決法

Last updated at Posted at 2023-12-25

注意
未経験エンジニアの場当たり的対処法になります。自分のメモ用に書いています。間違った説明があるかもしれません。
また、もっと良い方法がありましたら共有いただけたら幸甚です。

Host key verification failed.が出ました。

Rails7のアプリをHerokuでデプロイしていたら以下のエラーが出ました。

remote: -----> Installing node-v20.9.0-linux-x64
remote: -----> Installing yarn-v1.22.19
remote: -----> Detecting rake tasks
remote: -----> Preparing app for Rails asset pipeline
remote:        Running: rake assets:precompile
remote:        yarn install v1.22.19
remote:        warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
remote:        [1/4] Resolving packages...
remote:        [2/4] Fetching packages...
remote:        error Command failed.
remote:        Exit code: 128
remote:        Command: git
remote:        Arguments: ls-remote --tags --heads ssh://git@github.com/basecamp/idiomorph.git
remote:        Directory: /tmp/build_90ca0fb4
remote:        Output:
remote:        Host key verification failed.
remote:        fatal: Could not read from remote repository.
remote:
remote:        Please make sure you have the correct access rights
remote:        and the repository exists.
remote:        info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
buildpack: false
~
remote:        rake aborted!
remote:        jsbundling-rails: Command install failed, ensure yarn is installed
remote:        /tmp/build_90ca0fb4/vendor/bundle/ruby/3.1.0/gems/jsbundling-rails-1.2.1/lib/tasks/jsbundling/build.rake:6:in `block (2 levels) in <main>'
remote:        Tasks: TOP => assets:precompile => javascript:build => javascript:install
remote:        (See full trace by running task with --trace)
remote:
remote:  !
remote:  !     Precompiling assets failed.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.

ssh://git@github.com/basecamp/idiomorph.gitからインストールしたいものがあるのですが、Host key verification failed.が出てしまいうまくインストールすることができませんでした。

package-lock.jsonとyarn.lockが喧嘩してる?

warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.

こちらのwarningの内容からJSの管理ツールがpackage-lock.jsonとyarn.lockの2種類あることが原因ぽいです。

おそらくTailwindのFlowbiteを入れたときに新しくyarn.lockが生成されていたような気がします。

package-lock.jsonとyarn.lockがある場合は、yarn.lockの方を優先的に実行するみたいです。
2回目以降のデプロイだったため、以前package-lock.jsonでbasecamp/idiomorphをインストールしたときと鍵が違いますよとエラーが出ていたんだと思います。

色々調べた結果、buildpackのキャッシュをクリアするという方法を見つけたのですが、deploy.ymlの書き方が分からず断念しました……

喧嘩しているところを消す

単純にpackage-lock.jsonとyarn.lockが喧嘩しているならyarn.lockからbasecamp/idiomorphをインストールしている箇所を消せばいいのでは?と思い、消してherokuにpushしたらいけました!

とはいえ、今回は思いつきと言ってもいい方法で解決したので、これがいい方法だったのかは謎です。

参考

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