LoginSignup
0
0

More than 1 year has passed since last update.

git-credential-manager 影響下で git-remote-codecommit を使うと「配列の範囲が無効です」エラーが出る

Last updated at Posted at 2022-10-06

症状

WSL2 の Ubuntu 環境で陽気な開発作業をしていて、GitHub と AWS CodeCommit を両方使っています。認証情報をいちいち入力したくないので、GitHub では (Git for Windows 同梱の) git-credential-manager -core 1を、CodeCommit では git-remote-codecommit を使うことにします。

git-remote-codecommit は基本的に pip でインストールするだけで設定は要らない2ので、 git-credential-manager -core だけ Linux 用 Windows サブシステムで Git の使用を開始する - Microsoft Ignite などの記事を参考に

git config --global credential.helper "/mnt/c/Program\ Files/Git/mingw64/bin/git-credential-manager.exe"

と設定しました。

GitHub の pull/push はこれで全然問題ないのですが、CodeCommit (GRC 形式の URL) の pull/push しようとすると、できることはできるものの毎回心臓にわるいエラーメッセージが表示されます。

fatal: Failed to write item to store. [0x6c6]
fatal: 配列の範囲が無効です。

解決

git-credential-manager -core 影響下で git-remote-codecommit を使うのがよくないようです。ので、 git-credential-manager -core は GitHub にアクセスするときだけ効くように

# さっき追加したすべての URL に効く credential.helper は削除
git config --global --unset credential.helper
# git-credential-manager は GitHub だけに限定する
git config --global credential.https://github.com.helper "/mnt/c/Program\ Files/Git/mingw64/bin/git-credential-manager.exe"

とすることで、エラーメッセージから解放されました。

~/.gitconfig の内容はこんな感じです(user 部分は例です)。

$ cat ~/.gitconfig
[user]
        name = Taro Qiita
        email = taro-qiita@example.com
[credential "https://github.com"]
        helper = /mnt/c/Program\\ Files/Git/mingw64/bin/git-credential-manager.exe
  1. git-credential-manager-core は git-credential-manager に改名された そうなので、こちらの記事にも反映しました。Git for Windows の今日現在の最新版 2.39.0.2 では -core 付き/ -core なしの両方が入っていますが、-core 付きのほうを使うと warning: git-credential-manager-core was renamed to git-credential-manager と警告が出ます。

  2. AWS のアクセスキーなどの認証情報の設定はもちろん必要です。

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