snapの中で迷子になるgit-remote-https
こんにちは。静カニです。久しぶりの技術記事です。この間、manager.nvimに機能追加を行い、 その新機能を使いやすくするために新しいプラグインを作ろうとしていたのですが、ここで問題が発生しました。
※この記事は、Qiita gitアドベントカレンダー 2025に参加しています
tl;dr
ghでgit-remote-httpsがうんたらとか言い出したらsnap版じゃなくてapt版入れろ
環境
とりあえず環境書いておきます
- OS: Zorin OS 18 Core(ベースはUbuntu 24.04)
- snap: 2.72
- apt: 2.8.3
- 元のgit&ghのバージョン: 不明。ただしgit2.52, gh2.83ぐらいだと思われる
問題発生
$ 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すると普通に出来ます。
とりあえず私の解決までの道のりはこんな感じです。
解決までの道のり
ssh -T git@github.comでssh自体の生存を確認gh config set git_protocol sshで強制的にsshを使わせる→ダメgh auth refresh -s repoで再認証→ダメ- 今のsshを登録するときに昔のsshがあったことに気付く→削除→ダメ
~/.ssh/configがないことに気付く→作成&記入→ダメ- git本体の再インストール(
sudo apt update && sudo apt remove git && sudo apt install git)→ダメ which gitで場所確認→/usr/bin/gitなので割と普通- その他関連ライブラリを入れる(
sudo apt install libcurl4-openssl-dev libssl-dev expat libexpat1-dev gettext) →ダメ - エアーメッセージの
git-remote-httpsがどこにあるか確認する (find /usr -name "git-remote-https")→/usr/lib/git-core/git-remote-httpsにあったので標準的 $PATHに/usr/lib/git-coreを追加する→ダメ- git側が参照してるのが違う説(
git --exec-path)→/usr/lib/git-coreなので同じ - snapから入れていたのをaptから入れ直す→出来た
なんでこれでいけんの?
snapは隔離環境で動かしていて、中の世界にいるgit君が
外の世界にあるgit-remote-httpsにアクセスできなくて発狂していた模様。
一方でaptは、隔離していないため同じ世界にgh君とgit君とgit-remote-httpsが同居しているからいけるっぽい。
なのでその他snapで入れていたバグっているものがあったらaptで入れ直してみるのもいい手かも。
