LoginSignup
1
0

More than 1 year has passed since last update.

UbuntuでGithub CLIだけがwarning: templates not foundを吐く

Last updated at Posted at 2022-09-04

ただ単にGithubのissueを解読しただけなので簡潔に

症状詳細

Ubuntu20.04にて

$ gh repo clone sample-github/sample-repository
Cloning into 'sample-repository'...
warning: templates not found /usr/share/git-core/templates
fatal: Unable to find remote helper for 'https'
exit status 128

しかし普通にgitを使ったcloneではうまく行く。

$ git clone https://github.com/sample-github/sample-repository.git
Cloning into 'sample-repository'...
remote: Enumerating objects: 7, done.
remote: Counting objects: 100% (7/7), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 7 (delta 0), reused 4 (delta 0), pack-reused 0
Unpacking objects: 100% (7/7), 975 bytes | 975.00 KiB/s, done.

どういうことなの……?

最終的解決内容

snapではなくLinuxbrewのパッケージに変更した。

sudo snap remove gh
brew install gh

Linuxbrewのインストールは以下を参照。

ログイン(gh auth login)の後、確認

$ gh repo clone sample-github/sample-repository
Cloning into 'sample-repository'...
remote: Enumerating objects: 7, done.
remote: Counting objects: 100% (7/7), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 7 (delta 0), reused 4 (delta 0), pack-reused 0
Unpacking objects: 100% (7/7), 975 bytes | 325.00 KiB/s, done.

原因

以下のissueにまるまる答えがあった。
つまるところ、snapパッケージに問題があったということ。

Oh, then the problem is when gh runs as a snap. For that, you will have to contact the snap author and let them know of bugs that arise when using the snap.
In our experience, trying to package CLI apps as snaps is more trouble than it's worth, and I would suggest installing them "normally" instead, usually via deb packages or Homebrew. You will notice that we never listed snaps as a viable installation method in our documentation.

(大幅な意訳↓)

つまりsnapからインストールされたghが実行される場合が問題ということですね。これを解決するには、snapパッケージの作成者にバグを報告する必要があります。
経験上、CLIアプリケーションをsnapパッケージ化するには価値に見合わない労力が必要なので、snapからではなく「普通に」、すなわちHomebrewやdebパッケージからインストールすることをおすすめします。

これが今に至っても治っておらずさらに後述の通りglabでも同様のバグがある、ということはやはりsnap独自のシステムに問題があるのだろう。以下の記事でも指摘されている。

debパッケージからインストールする場合

snapが使えるならたいていLinuxbrewも使えると思うのでHideにしておきます

GithubのReleasesから自分のコンピュータに見合うパッケージをダウンロード。

ダウンロードしたら、保存先で

sudo apt install ./gh_*

を叩けばインストール完了。

おまけ:glabの場合

glab(GitLabのCLIツール)でも同様の症状がおきたので参考までに。

$ glab repo clone gitlab-tests/sample-project
Cloning into 'sample-project'...
warning: templates not found /usr/share/git-core/templates
fatal: Unable to find remote helper for 'https'
exit status 128

同様に

sudo snap remove glab
brew install glab

ログイン(glab auth login)後、確認

glab repo clone gitlab-tests/sample-project
Cloning into 'sample-project'...
remote: Enumerating objects: 12, done.
remote: Total 12 (delta 0), reused 0 (delta 0), pack-reused 12
Unpacking objects: 100% (12/12), 30.71 KiB | 6.14 MiB/s, done.

まとめ

特にCLIアプリについては、可能な限りsnapからのインストールは避けよう。

1
0
1

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
1
0