0
0

More than 1 year has passed since last update.

go mod tidyでgitlabのリポジトリimportが失敗する

Posted at

はじめに

本記事はあくまで個人のタスクにおける備忘録としての投稿であり、細かい設定条件や開発環境の記載は省略しています。

事象

go mod tidyで依存関係を整理しようとした際に

fatal: could not read Username for 'https://gitlab.***/***/***.git': terminal prompts disabled
Confirm the import path was entered correctly.

というエラーが出て失敗する。

調査

  1. エラー内容をそのままググる
    するとこういう記事がヒットする
    https://jnst.hateblo.jp/entry/2016/10/17/210612

    要はgitのレポジトリへのアクセスをする際に権限がないため怒られているとのこと。

  2. 現状の.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 pullgit pushする際にユーザー情報聞かれてたなと。。
ただ.netrcには必要情報記載してあるし.gitconfigにも名前とトークン情報が記載されていた
.netrcにはemail情報不要のため気付くのが遅れた)

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