Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't go get cli cobra #1348

Closed
andrewh1978 opened this issue Feb 12, 2021 · 17 comments
Closed

Can't go get cli cobra #1348

andrewh1978 opened this issue Feb 12, 2021 · 17 comments

Comments

@andrewh1978
Copy link

This was previously reported in #1345 by someone else, but was closed with no comment. It is easily reproducible:

$ docker run -it centos:7 bash
[root@fd7977aec9a1 /]# curl -s https://mirror.go-repo.io/centos/go-repo.repo >/etc/yum.repos.d/go-repo.repo
[root@fd7977aec9a1 /]# yum install -y golang git
[root@fd7977aec9a1 /]# [root@fd7977aec9a1 /]# go version
go version go1.15.8 linux/amd64
[root@fd7977aec9a1 /]# go get -v -u github.com/spf13/cobra/cobra
github.com/spf13/cobra (download)
github.com/mitchellh/go-homedir (download)
github.com/spf13/pflag (download)
github.com/spf13/viper (download)
github.com/fsnotify/fsnotify (download)
get "golang.org/x/sys/unix": found meta tag get.metaImport{Prefix:"golang.org/x/sys", VCS:"git", RepoRoot:"https://go.googlesource.com/sys"} at //golang.org/x/sys/unix?go-get=1
get "golang.org/x/sys/unix": verifying non-authoritative meta tag
golang.org/x/sys (download)
get "golang.org/x/sys/internal/unsafeheader": found meta tag get.metaImport{Prefix:"golang.org/x/sys", VCS:"git", RepoRoot:"https://go.googlesource.com/sys"} at //golang.org/x/sys/internal/unsafeheader?go-get=1
get "golang.org/x/sys/internal/unsafeheader": verifying non-authoritative meta tag
github.com/hashicorp/hcl (download)
github.com/agext/levenshtein (download)
github.com/apparentlymart/go-textseg (download)
github.com/mitchellh/go-wordwrap (download)
github.com/zclconf/go-cty (download)
get "golang.org/x/text/unicode/norm": found meta tag get.metaImport{Prefix:"golang.org/x/text", VCS:"git", RepoRoot:"https://go.googlesource.com/text"} at //golang.org/x/text/unicode/norm?go-get=1
get "golang.org/x/text/unicode/norm": verifying non-authoritative meta tag
golang.org/x/text (download)
get "golang.org/x/text/transform": found meta tag get.metaImport{Prefix:"golang.org/x/text", VCS:"git", RepoRoot:"https://go.googlesource.com/text"} at //golang.org/x/text/transform?go-get=1
get "golang.org/x/text/transform": verifying non-authoritative meta tag
cannot find package "github.com/hashicorp/hcl/hcl/printer" in any of:
	/usr/lib/golang/src/github.com/hashicorp/hcl/hcl/printer (from $GOROOT)
	/root/go/src/github.com/hashicorp/hcl/hcl/printer (from $GOPATH)
github.com/magiconair/properties (download)
github.com/mitchellh/mapstructure (download)
github.com/pelletier/go-toml (download)
github.com/spf13/afero (download)
github.com/spf13/cast (download)
github.com/spf13/jwalterweatherman (download)
github.com/subosito/gotenv (download)
get "gopkg.in/ini.v1": found meta tag get.metaImport{Prefix:"gopkg.in/ini.v1", VCS:"git", RepoRoot:"https://gopkg.in/ini.v1"} at //gopkg.in/ini.v1?go-get=1
gopkg.in/ini.v1 (download)
get "gopkg.in/yaml.v2": found meta tag get.metaImport{Prefix:"gopkg.in/yaml.v2", VCS:"git", RepoRoot:"https://gopkg.in/yaml.v2"} at //gopkg.in/yaml.v2?go-get=1
gopkg.in/yaml.v2 (download)
@harrysungod
Copy link

Temp workaround seems to work for me, may be master has the fix?

From a checkout of this repo, run go install -x -v github.com/spf13/cobra/cobra . Binary will be in typical install directory, say, $GOPATH/bin

andrewh1978 pushed a commit to andrewh1978/px-deploy that referenced this issue Feb 12, 2021
@cemery-tibco
Copy link

I am having the same issue, and the workaround mentioned in #1345 doesn't work for me, I get: go: unknown environment setting GO111MODULE=ON

This is on go1.15.6

@GonzalezAndrew
Copy link

GonzalezAndrew commented Feb 15, 2021

I was unable to recreate the issues you are facing. When you set the GO111MODULE, how are you doing so?

This is the output I am seeing when using the same workflow you stated above

$ docker run -it centos:7 bash
[root@856ca05b1127 /]# curl -s https://mirror.go-repo.io/centos/go-repo.repo >/etc/yum.repos.d/go-repo.repo
[root@856ca05b1127 /]# yum install -y golang git
[root@856ca05b1127 /]#  go version
go version go1.15.8 linux/amd64
[root@856ca05b1127 /]# go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/root/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/root/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/golang"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/golang/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build222391962=/tmp/go-build -gno-record-gcc-switches"
[root@856ca05b1127 /]# export GO111MODULE="on"
[root@856ca05b1127 /]# go get -v -u github.com/spf13/cobra/cobra
go: downloading github.com/spf13/cobra v1.1.3
go: found github.com/spf13/cobra/cobra in github.com/spf13/cobra v1.1.3
go: downloading github.com/mitchellh/go-homedir v1.1.0
go: downloading github.com/spf13/viper v1.7.0
go: downloading github.com/inconshreveable/mousetrap v1.0.0
go: downloading github.com/spf13/pflag v1.0.5
go: downloading github.com/spf13/cast v1.3.0
go: downloading github.com/hashicorp/hcl v1.0.0
go: downloading github.com/mitchellh/mapstructure v1.1.2
go: downloading gopkg.in/ini.v1 v1.51.0
go: downloading github.com/subosito/gotenv v1.2.0
go: downloading gopkg.in/yaml.v2 v2.4.0
go: downloading github.com/pelletier/go-toml v1.2.0
go: downloading github.com/magiconair/properties v1.8.1
go: downloading github.com/spf13/jwalterweatherman v1.0.0
go: downloading github.com/spf13/afero v1.1.2
go: downloading github.com/fsnotify/fsnotify v1.4.7
go: downloading golang.org/x/text v0.3.2
go: downloading golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0
go: github.com/mitchellh/go-homedir upgrade => v1.1.0
go: github.com/pelletier/go-toml upgrade => v1.8.1
go: github.com/spf13/cast upgrade => v1.3.1
go: gopkg.in/ini.v1 upgrade => v1.62.0
go: github.com/mitchellh/mapstructure upgrade => v1.4.1
go: golang.org/x/sys upgrade => v0.0.0-20210124154548-22da62e12c0c
go: github.com/spf13/afero upgrade => v1.5.1
go: github.com/fsnotify/fsnotify upgrade => v1.4.9
go: github.com/spf13/pflag upgrade => v1.0.5
go: github.com/spf13/viper upgrade => v1.7.1
go: github.com/magiconair/properties upgrade => v1.8.4
go: github.com/spf13/jwalterweatherman upgrade => v1.1.0
go: golang.org/x/text upgrade => v0.3.5
go: gopkg.in/yaml.v2 upgrade => v2.4.0
go: downloading github.com/spf13/viper v1.7.1
go: downloading github.com/mitchellh/mapstructure v1.4.1
go: downloading github.com/spf13/afero v1.5.1
go: downloading github.com/pelletier/go-toml v1.8.1
go: downloading github.com/fsnotify/fsnotify v1.4.9
go: downloading github.com/magiconair/properties v1.8.4
go: downloading github.com/spf13/jwalterweatherman v1.1.0
go: downloading gopkg.in/ini.v1 v1.62.0
go: downloading github.com/spf13/cast v1.3.1
go: downloading golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c
go: downloading golang.org/x/text v0.3.5
github.com/spf13/cobra/cobra/tpl
golang.org/x/sys/internal/unsafeheader
github.com/hashicorp/hcl/hcl/strconv
golang.org/x/text/transform
github.com/spf13/afero/mem
github.com/mitchellh/go-homedir
github.com/subosito/gotenv
github.com/spf13/jwalterweatherman
github.com/mitchellh/mapstructure
gopkg.in/ini.v1
github.com/spf13/pflag
github.com/pelletier/go-toml
golang.org/x/sys/unix
github.com/hashicorp/hcl/hcl/token
gopkg.in/yaml.v2
github.com/spf13/cast
github.com/magiconair/properties
golang.org/x/text/unicode/norm
github.com/hashicorp/hcl/hcl/ast
github.com/hashicorp/hcl/hcl/scanner
github.com/hashicorp/hcl/json/token
github.com/hashicorp/hcl/json/scanner
github.com/hashicorp/hcl/hcl/parser
github.com/hashicorp/hcl/json/parser
github.com/hashicorp/hcl/hcl/printer
github.com/hashicorp/hcl
github.com/spf13/afero
github.com/spf13/cobra
github.com/fsnotify/fsnotify
github.com/spf13/viper
github.com/spf13/cobra/cobra/cmd
github.com/spf13/cobra/cobra
[root@856ca05b1127 /]#

@andrewmyhre
Copy link

@cemery-tibco Try lowercase on

export GOMODULE111=on
go get -v -u github.com/spf13/cobra/cobra

@greenenergy
Copy link

I was unable to install cobra cli as well, with no errors or warnings. It seemed to run to completion but without actually installing the cobra binary.

After going into the actual cobra source code downloaded and trying to manually make it there, there were two things I had to install to get it to work (which came from the make logs):

curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh

and
go get -u github.com/kyoh86/richgo

After doing both of those, I was able to just do the cobra install as per the instructions and it worked.

@Nesaijn
Copy link

Nesaijn commented Mar 19, 2021

@greenenergy 's solution did not change anything for me

Where does go get its environment variables anyway? I did set the environment variables with export

vagrant@vagrant:~$ go version
go version go1.10.4 linux/amd64

vagrant@vagrant:~$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/vagrant/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/vagrant/go"
GORACE=""
GOROOT="/usr/lib/go-1.10"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.10/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build368447797=/tmp/go-build -gno-record-gcc-switches"

vagrant@vagrant:~$ env | grep GO
GO111MODULE=on
GOMODULE111=on

vagrant@vagrant:~$ go get -v -u github.com/spf13/cobra/cobra
github.com/spf13/cobra (download)
github.com/mitchellh/go-homedir (download)
github.com/spf13/pflag (download)
github.com/spf13/viper (download)
github.com/fsnotify/fsnotify (download)
Fetching https://golang.org/x/sys/unix?go-get=1
Parsing meta tags from https://golang.org/x/sys/unix?go-get=1 (status code 200)
get "golang.org/x/sys/unix": found meta tag get.metaImport{Prefix:"golang.org/x/sys", VCS:"git", RepoRoot:"https://go.googlesource.com/sys"} at https://golang.org/x/sys/unix?go-get=1
get "golang.org/x/sys/unix": verifying non-authoritative meta tag
Fetching https://golang.org/x/sys?go-get=1
Parsing meta tags from https://golang.org/x/sys?go-get=1 (status code 200)
golang.org/x/sys (download)
Fetching https://golang.org/x/sys/internal/unsafeheader?go-get=1
Parsing meta tags from https://golang.org/x/sys/internal/unsafeheader?go-get=1 (status code 200)
get "golang.org/x/sys/internal/unsafeheader": found meta tag get.metaImport{Prefix:"golang.org/x/sys", VCS:"git", RepoRoot:"https://go.googlesource.com/sys"} at https://golang.org/x/sys/internal/unsafeheader?go-get=1
get "golang.org/x/sys/internal/unsafeheader": verifying non-authoritative meta tag
github.com/hashicorp/hcl (download)
github.com/agext/levenshtein (download)
github.com/apparentlymart/go-textseg (download)
github.com/mitchellh/go-wordwrap (download)
github.com/zclconf/go-cty (download)
Fetching https://golang.org/x/text/unicode/norm?go-get=1
Parsing meta tags from https://golang.org/x/text/unicode/norm?go-get=1 (status code 200)
get "golang.org/x/text/unicode/norm": found meta tag get.metaImport{Prefix:"golang.org/x/text", VCS:"git", RepoRoot:"https://go.googlesource.com/text"} at https://golang.org/x/text/unicode/norm?go-get=1
get "golang.org/x/text/unicode/norm": verifying non-authoritative meta tag
Fetching https://golang.org/x/text?go-get=1
Parsing meta tags from https://golang.org/x/text?go-get=1 (status code 200)
golang.org/x/text (download)
Fetching https://golang.org/x/text/transform?go-get=1
Parsing meta tags from https://golang.org/x/text/transform?go-get=1 (status code 200)
get "golang.org/x/text/transform": found meta tag get.metaImport{Prefix:"golang.org/x/text", VCS:"git", RepoRoot:"https://go.googlesource.com/text"} at https://golang.org/x/text/transform?go-get=1
get "golang.org/x/text/transform": verifying non-authoritative meta tag
package github.com/hashicorp/hcl/hcl/printer: cannot find package "github.com/hashicorp/hcl/hcl/printer" in any of:
	/usr/lib/go-1.10/src/github.com/hashicorp/hcl/hcl/printer (from $GOROOT)
	/home/vagrant/go/src/github.com/hashicorp/hcl/hcl/printer (from $GOPATH)
github.com/magiconair/properties (download)
github.com/mitchellh/mapstructure (download)
github.com/pelletier/go-toml (download)
github.com/spf13/afero (download)
github.com/spf13/cast (download)
github.com/spf13/jwalterweatherman (download)
github.com/subosito/gotenv (download)
Fetching https://gopkg.in/ini.v1?go-get=1
Parsing meta tags from https://gopkg.in/ini.v1?go-get=1 (status code 200)
get "gopkg.in/ini.v1": found meta tag get.metaImport{Prefix:"gopkg.in/ini.v1", VCS:"git", RepoRoot:"https://gopkg.in/ini.v1"} at https://gopkg.in/ini.v1?go-get=1
gopkg.in/ini.v1 (download)
Fetching https://gopkg.in/yaml.v2?go-get=1
Parsing meta tags from https://gopkg.in/yaml.v2?go-get=1 (status code 200)
get "gopkg.in/yaml.v2": found meta tag get.metaImport{Prefix:"gopkg.in/yaml.v2", VCS:"git", RepoRoot:"https://gopkg.in/yaml.v2"} at https://gopkg.in/yaml.v2?go-get=1
gopkg.in/yaml.v2 (download)

@Nesaijn
Copy link

Nesaijn commented Mar 22, 2021

I just noticed that while getting the errors mentioned above on go version 1.10.4 I did not get them on go version 1.16.2

@rocktavious
Copy link

I can confirm that upgrading from go 1.15 -> 1.16.2 fixed the issue for me

@jjanvier
Copy link

I'm having the same problem with Go 1.16.2

@or1can
Copy link

or1can commented Apr 13, 2021

I ran into the same issue, but migrating to Go Modules as described here hashicorp/hcl#449 (comment) helped me

@georgettica
Copy link
Contributor

georgettica commented Apr 20, 2021

I was unable to install cobra cli as well, with no errors or warnings. It seemed to run to completion but without actually installing the cobra binary.

After going into the actual cobra source code downloaded and trying to manually make it there, there were two things I had to install to get it to work (which came from the make logs):

curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh

and
go get -u github.com/kyoh86/richgo

After doing both of those, I was able to just do the cobra install as per the instructions and it worked.

I got the same issue in the build checks..
Should the go.mod include github.com/kyoh86/richgo?

Ref to err https://github.com/spf13/cobra/runs/2394764837?check_suite_focus=true

@github-actions
Copy link

This issue is being marked as stale due to a long period of inactivity

@georgettica
Copy link
Contributor

For now I will close based in suggestion in #1393 , but if this happens again to someone please reopen

@chetrf
Copy link

chetrf commented Jul 9, 2021

go get -u github.com/spf13/cobra/cobra seems to work for me. I am on MacOs and here is a screen shot of my terminal session that shows the sequence of events to get it to work.
2021-07-09_10-22-27

@jpmcb
Copy link
Collaborator

jpmcb commented Dec 9, 2021

Closing.

go get works as expected:

vagrant@ubuntu-focal:~$ go version
go version go1.16.6 linux/amd64

vagrant@ubuntu-focal:~$ mkdir test-cobra

vagrant@ubuntu-focal:~$ cd test-cobra

vagrant@ubuntu-focal:~/test-cobra$ go mod init example.com
go: creating new go.mod: module example.com

vagrant@ubuntu-focal:~/test-cobra$ go get github.com/spf13/cobra
go: downloading github.com/spf13/cobra v1.2.1
go: downloading github.com/inconshreveable/mousetrap v1.0.0
go: downloading github.com/spf13/pflag v1.0.5
go get: added github.com/spf13/cobra v1.2.1

vagrant@ubuntu-focal:~/test-cobra$ cat go.mod
module example.com

go 1.16

require github.com/spf13/cobra v1.2.1 // indirect

and installing the cobra CLI tool works as expected as mentioned in #1393 and in previous comments:

@jpmcb jpmcb closed this as completed Dec 9, 2021
@jsburckhardt
Copy link

Go Get in module mode is deprecated. You'll need to use something like GO111MODULE=on go install github.com/spf13/cobra/cobra@latest

@tat2bu
Copy link

tat2bu commented May 6, 2022

I had to use go get -u github.com/spf13/cobra@latest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests