IntelliJ Throws error fatal: 'origin' does not appear to be a git repository. Trying to install a module with go get

huangapple go评论78阅读模式
英文:

IntelliJ Throws error fatal: 'origin' does not appear to be a git repository. Trying to install a module with go get

问题

我正在尝试在我的GO项目中安装Prometheus,使用以下命令在我的IntelliJ终端中:

go get github.com/prometheus/client_golang/prometheus

但是当我这样做时,我遇到了以下错误:

GOROOT=/usr/lib/golang #gosetup
GOPATH=/home/yakiza #gosetup
/usr/lib/golang/bin/go list -modfile=/home/yakiza/IdeaProjects/Zephyros/go.mod -m -json -mod=mod all #gosetup
go: github.com/prometheus/client_golang@v1.12.2 requires
	github.com/prometheus/common@v0.32.1 requires
	golang.org/x/oauth2@v0.0.0-20210514164344-f6687ab2804c requires
	cloud.google.com/go@v0.65.0 requires
	github.com/google/pprof@v0.0.0-20200708004538-1a94d8640e99 requires
	github.com/chzyer/readline@v0.0.0-20180603132655-2972be24d48e: invalid version: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /home/yakiza/pkg/mod/cache/vcs/2b1d73c01d25b37519a4c8fa4a9da66549ac9cb349c7eed83e8fc258c189ca92: exit status 128:
	fatal: 'origin' does not appear to be a git repository
	fatal: Could not read from remote repository.
	
	Please make sure you have the correct access rights
	and the repository exists.

我注意到,如果我继续使用终端(而不是IDE)安装模块,一切都会正确安装,但是当我用IDE打开项目时,错误仍然存在,我无法成功运行我的项目。

我尝试删除项目中的包,但没有成功。此外,我还尝试在使用IntelliJ的另一个项目上安装模块,出现了相同的问题。
1: https://prometheus.io/docs/guides/go-application/

英文:

I am trying to install Prometheus on my GO project using the following command inside my intelliJ terminal:

go get github.com/prometheus/client_golang/prometheus

and when I do so I am getting the following error:

GOROOT=/usr/lib/golang #gosetup
GOPATH=/home/yakiza #gosetup
/usr/lib/golang/bin/go list -modfile=/home/yakiza/IdeaProjects/Zephyros/go.mod -m -json -mod=mod all #gosetup
go: github.com/prometheus/client_golang@v1.12.2 requires
	github.com/prometheus/common@v0.32.1 requires
	golang.org/x/oauth2@v0.0.0-20210514164344-f6687ab2804c requires
	cloud.google.com/go@v0.65.0 requires
	github.com/google/pprof@v0.0.0-20200708004538-1a94d8640e99 requires
	github.com/chzyer/readline@v0.0.0-20180603132655-2972be24d48e: invalid version: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /home/yakiza/pkg/mod/cache/vcs/2b1d73c01d25b37519a4c8fa4a9da66549ac9cb349c7eed83e8fc258c189ca92: exit status 128:
	fatal: 'origin' does not appear to be a git repository
	fatal: Could not read from remote repository.
	
	Please make sure you have the correct access rights
	and the repository exists.

I noticed that if I go ahead and try to install the module using the the terminal ( not inside the IDE) everything gets installed properly, but when I open the project with the IDE the error still stands and I cannot run my project successfully.

I tried to delete the packages from the project, with no success. Additionally tried to install the module on another project using IntelliJ same issue.
1: https://prometheus.io/docs/guides/go-application/

答案1

得分: 1

我到处查找解决方案,但不幸的是,我没有找到这个问题的根本原因。

我可以确定的是,这是IntelliJ中的某个问题,原因是我恢复了IDE的设置

从主菜单中选择 文件 | 管理IDE设置 | 恢复默认设置。

然后重新启动我的IDE,一切都按预期工作了。

英文:

I looked everywhere to try and find a solution for this, but unfortunately I was not able to find the root cause of this.

I can say for certain that is something within IntelliJ causing this, and the reason for that I restored the IDE settings

From the main menu, select File | Manage IDE Settings | Restore Default Settings.

Then restarted my IDE and everything works as expected

huangapple
  • 本文由 发表于 2022年6月29日 07:28:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/72794207.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定