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

protoc-gen-gocosmos: program not found or is not executable #2171

Closed
sajshuai opened this issue Mar 17, 2022 · 15 comments · Fixed by #2174
Closed

protoc-gen-gocosmos: program not found or is not executable #2171

sajshuai opened this issue Mar 17, 2022 · 15 comments · Fixed by #2174
Labels
report type:bug Something isn't working

Comments

@sajshuai
Copy link

Describe the bug
error while running command /tmp/protoc194239331: mars/query.proto:6:1: warning: Import cosmos/base/query/v1beta1/pagination.proto is unused.
protoc-gen-gocosmos: program not found or is not executable
Please specify a program using absolute path or make sure the program is available in your PATH system variable
--gocosmos_out: protoc-gen-gocosmos: Plugin failed with status code 1.
: exit status 1

Please provide the version output
Starport version: v0.19.2
Starport build date: 2022-01-19T11:16:41Z
Starport source hash: -
Your OS: linux
Your arch: amd64
Your go version: go version go1.18 linux/amd64

@fadeev
Copy link
Contributor

fadeev commented Mar 17, 2022

We had a similar issue a while back: #1584

Can you, please, provide the output of echo $PATH.

@sajshuai
Copy link
Author

export GOROOT=/usr/local/go
export GOPATH=/data/scripts/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

I had add gopath to PATH,but $GOPATH/bin is empty .
#1584 is changing ubuntu 18.04 to ubuntu 20.04,but my system already is ubuntu 20.04

@dave
Copy link
Contributor

dave commented Mar 17, 2022

I'm having the same problem... It looks like protoc-gen-gocosmos is installed here... I think you need to run go install, not go get to install binaries nowadays... however it looks like protoc-gen-gocosmos uses a replace directive in the go.mod which is incompatible with go install?

$ go install github.com/regen-network/cosmos-proto/protoc-gen-gocosmos@latest
go: github.com/regen-network/cosmos-proto/protoc-gen-gocosmos@latest (in github.com/regen-network/cosmos-proto@v0.3.1):
	The go.mod file for the module providing named packages contains one or
	more replace directives. It must not contain directives that would cause
	it to be interpreted differently than if it were the main module.

@dave
Copy link
Contributor

dave commented Mar 17, 2022

Background reading here...

@dave
Copy link
Contributor

dave commented Mar 17, 2022

OK you can get this working by running go get xxx followed by go install xxx inside the module. However I think this is non optimal... It adds protobuf tooling related stuff to the go.mod of the scaffolded project, which shouldn't be needed.

However, without removing the replace directive from the gocosmos project, it might be impossible to install it globally? @aaronc might want to take a look at this.

@sajshuai
Copy link
Author

I find the "protoc-gen-gocosmos" package in GOPATH/pkg/mod/github.com/regen-network/cosmos-proto@v0.3.1
and run "go install ./protoc-gen-gocosmos".
It's ok now .
thanks @dave

@dave
Copy link
Contributor

dave commented Mar 17, 2022

I don't think this should be closed... there is definitely a bug in starport code...

@fadeev
Copy link
Contributor

fadeev commented Mar 17, 2022

When scaffolding a chain Starport installs protoc binaries in ~/go/bin:

~ % ls ~/go/bin
protoc-gen-go		protoc-gen-grpc-gateway	protoc-gen-swagger
protoc-gen-gocosmos	protoc-gen-openapiv2

Hence, the question is the same, what is the output of the following command on your machine:

echo $PATH

@fadeev fadeev reopened this Mar 17, 2022
@dave
Copy link
Contributor

dave commented Mar 17, 2022

When scaffolding a chain Starport installs protoc binaries in ~/go/bin:

I'm pretty sure this is not the case for later versions of Go... I'm using Go 1.18 and it definitely doesn't work like that. The installer just runs go get github.com/regen-network/cosmos-proto/protoc-gen-gocosmos in the module directory. This does not install the binary. Earlier versions of Go would have installed the binary with this command.

@dave
Copy link
Contributor

dave commented Mar 17, 2022

Consider these commands:

[1] $ mkdir bar
[2] $ cd bar
[3] $ go mod init github.com/dave/bar
go: creating new go.mod: module github.com/dave/bar
[4] $ cat go.mod
module github.com/dave/bar

go 1.18
[5] $ which protoc-gen-gocosmos
[6] $ go get github.com/regen-network/cosmos-proto/protoc-gen-gocosmos
go: downloading github.com/gogo/protobuf v1.3.2
go: added github.com/gogo/protobuf v1.3.2
go: added github.com/regen-network/cosmos-proto v0.3.1
[7] $ which protoc-gen-gocosmos
[8] $ cat go.mod
module github.com/dave/bar

go 1.18

require (
	github.com/gogo/protobuf v1.3.2 // indirect
	github.com/regen-network/cosmos-proto v0.3.1 // indirect
)
[9] $ go install github.com/regen-network/cosmos-proto/protoc-gen-gocosmos
[10] $ which protoc-gen-gocosmos
/Users/dave/bin/protoc-gen-gocosmos

[1, 2, 3] Creates a new go module and initialises.
[4] Shows the contents of go.mod (empty)
[5] Shows that protoc-gen-gocosmos does not exist in the path
[6] Runs go get
[7] Shows that protoc-gen-gocosmos still does not exist in the path
[8] Shows the contents of go.mod, which has been updated by go get as if protoc-gen-gocosmos was a library we're importing in our code.
[9] Runs go install to install the version of protoc-gen-gocosmos that is local to the module.
[10] Shows that protoc-gen-gocosmos is now installed in the path.

@dave
Copy link
Contributor

dave commented Mar 17, 2022

Newer versions of Go have changed the behaviour of go get and go install...

Running go get followed by go install in the module directory works, but it's not ideal... Instead we want to run go install outside of the module directory. This should install the binary without polluting go.mod with references to the tooling Go packages...

However, running go install outside the module directory is incompatible with the replace directive in the protoc-gen-gocosmos project...

@sajshuai
Copy link
Author

I may be found the problem.I'm not logged in as root, and golang is install in /usr/local/bin.
However,"rotoc-gen-go protoc-gen-gocosmos protoc-gen-grpc-gateway protoc-gen-openapiv2 protoc-gen-swagger" are all installed in "/root/go/bin".
My root user does not have golang env.
I don't know why they installed in /root/go/bin.
when #1584 changing ubuntu 18.04 to ubuntu 20.04,he may logged in as root,so he solved the problem.

@fadeev fadeev added the type:bug Something isn't working label Mar 18, 2022
@joshuacheong
Copy link

joshuacheong commented Mar 18, 2022

I face the same issues, I believe the issue is traced to the following deprecation of "go get" from Go 1.18, go get will no longer build packages:
https://go.dev/doc/go-get-install-deprecation#:~:text=Starting%20in%20Go%201.17%2C%20installing,the%20%2Dd%20flag%20were%20enabled.

I overcame the issue by reinstalling Go 1.17.8 instead. I would suggest raising a pull request to change "get" command with "install" command.

@ilgooz
Copy link
Member

ilgooz commented Mar 18, 2022

Thank you all of you for raising this up and thanks @dave for the PR!

The fix has been merged to develop and it'll we be released soon with a point release (v0.19.5). Meanwhile, if you don't want to wait, you can install Starport CLI Nightly from here.

Be aware that Nightly version is built from develop and it may contain features that may not be shipped by v0.19.5.

Please let us know if your problem persists after upgrading, happy weekend!

@ilgooz
Copy link
Member

ilgooz commented Mar 19, 2022

For those who were experiencing protoc-gen-gocosmos problem, please install the new release v0.19.5: https://github.com/tendermint/starport/releases/tag/v0.19.5

See how to upgrade: https://docs.starport.network/guide/install.html#upgrading-your-starport-installation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
report type:bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants