タイトル画像

snapの中で迷子になるgit-remote-https

こんにちは。静カニです。久しぶりの技術記事です。この間、manager.nvimに機能追加を行い、 その新機能を使いやすくするために新しいプラグインを作ろうとしていたのですが、ここで問題が発生しました。

※この記事は、Qiita gitアドベントカレンダー 2025に参加しています

tl;dr

ghでgit-remote-httpsがうんたらとか言い出したらsnap版じゃなくてapt版入れろ

環境

とりあえず環境書いておきます

問題発生

$ gh repo create
What would you like to do? Create a new repository on GitHub from scratch
Repository name manager-logs
Description 
Visibility Public
Would you like to add a README file? Yes
Would you like to add a .gitignore file? No
Would you like to add a license? Yes
Choose a license MIT license
This will create "manager-logs" as a public repository on GitHub. Continue? Yes
Clone the new repository locally? Yes

warning: templates not found in /usr/share/git-core/templates
git: 'remote-https' is not a git command. See 'git --help'.
failed to run git: exit status 128

という感じです。ちなみにPublicリポジトリを gh repo clone でクローンしようとしても同じエラー(警告)が出ます。 今の環境に移ってからというよりは、sshを始めてからこのエラーが出ていそうです。 さらにちなむとgit cloneでsshすると普通に出来ます。 とりあえず私の解決までの道のりはこんな感じです。

解決までの道のり

  1. ssh -T git@github.com でssh自体の生存を確認
  2. gh config set git_protocol sshで強制的にsshを使わせる→ダメ
  3. gh auth refresh -s repoで再認証→ダメ
  4. 今のsshを登録するときに昔のsshがあったことに気付く→削除→ダメ
  5. ~/.ssh/configがないことに気付く→作成&記入→ダメ
  6. git本体の再インストール(sudo apt update && sudo apt remove git && sudo apt install git)→ダメ
  7. which gitで場所確認→/usr/bin/gitなので割と普通
  8. その他関連ライブラリを入れる(sudo apt install libcurl4-openssl-dev libssl-dev expat libexpat1-dev gettext) →ダメ
  9. エアーメッセージのgit-remote-httpsがどこにあるか確認する (find /usr -name "git-remote-https")→/usr/lib/git-core/git-remote-httpsにあったので標準的
  10. $PATH/usr/lib/git-coreを追加する→ダメ
  11. git側が参照してるのが違う説(git --exec-path)→/usr/lib/git-coreなので同じ
  12. snapから入れていたのをaptから入れ直す→出来た

なんでこれでいけんの?

snapは隔離環境で動かしていて、中の世界にいるgit君が 外の世界にあるgit-remote-httpsにアクセスできなくて発狂していた模様。 一方でaptは、隔離していないため同じ世界にgh君とgit君とgit-remote-httpsが同居しているからいけるっぽい。

なのでその他snapで入れていたバグっているものがあったらaptで入れ直してみるのもいい手かも。