はじめに
本記事はあくまで個人のタスクにおける備忘録としての投稿であり、細かい設定条件や開発環境の記載は省略しています。
事象
go mod tidyで依存関係を整理しようとした際に
fatal: could not read Username for 'https://gitlab.***/***/***.git': terminal prompts disabled
Confirm the import path was entered correctly.
というエラーが出て失敗する。
調査
-
エラー内容をそのままググる
するとこういう記事がヒットする
https://jnst.hateblo.jp/entry/2016/10/17/210612要はgitのレポジトリへのアクセスをする際に権限がないため怒られているとのこと。
-
現状の
.gitconfigを見てみる。
[credential]
helper = !aws codecommit credential-helper $@
UseHttpPath = true
[core]
editor = /usr/bin/vim
[url "git@gitlab.***:****"]
insteadOf = https:/gitlab-ci-token:<gitlabのアクセストークン>@/gitlab.*****
[user]
name = *********
<分かったこと>
・アクセストークンは発行してあるし記載されている。
・insteadOfの記載もある。
・user情報のnameは記載されているが、アドレスがない...?(なんで?消した)
解決方法
.gitconfigのuser情報にアドレスを記載する。
[credential]
helper = !aws codecommit credential-helper $@
UseHttpPath = true
[core]
editor = /usr/bin/vim
[url "git@gitlab.***:****"]
insteadOf = https:/gitlab-ci-token:<gitlabのアクセストークン>@/gitlab.*****
[user]
name = *********
email = ******@***.co.jp
できた。
そういえば
そういえばgit pullやgit pushする際にユーザー情報聞かれてたなと。。
ただ.netrcには必要情報記載してあるし.gitconfigにも名前とトークン情報が記載されていた
(.netrcにはemail情報不要のため気付くのが遅れた)