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

Fix installation of gocosmos #7410

Merged
merged 11 commits into from
Oct 1, 2020
Merged

Fix installation of gocosmos #7410

merged 11 commits into from
Oct 1, 2020

Conversation

amaury1093
Copy link
Contributor

@amaury1093 amaury1093 commented Sep 29, 2020

Description

the command go get github.com/regen-network/cosmos-proto/protoc-gen-gocosmos needs to run in the root folder, to be aware of the replace we added in go.mod.


I then ran make proto-gen with the following versions:

PROTOC_VERSION=3.13.0
PROTOC_GRPC_GATEWAY_VERSION=1.14.7

➜  cosmos-sdk git:(am-proto-gen) protoc --version
libprotoc 3.13.0
➜  cosmos-sdk git:(am-proto-gen) protoc-gen-grpc-gateway --version
Version 1.14.7, commit 37837bc5882204897dfb5b17ee231fc645c9102d, built at 2020-08-12T08:49:14Z

Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes

@amaury1093
Copy link
Contributor Author

amaury1093 commented Sep 29, 2020

Could someone with the correct version also run make proto-gen, and make sure there's no diff? 🙏 (except maybe staking.pb.go)

@amaury1093 amaury1093 marked this pull request as draft September 29, 2020 13:49
types/abci.pb.go Outdated Show resolved Hide resolved
@alexanderbez
Copy link
Contributor

Confirmed I have no diff!

@amaury1093 amaury1093 changed the title Run make proto-gen with correct version Fix installation of gocosmos Sep 29, 2020
@amaury1093 amaury1093 marked this pull request as ready for review September 29, 2020 17:10
@codecov
Copy link

codecov bot commented Sep 29, 2020

Codecov Report

Merging #7410 into master will decrease coverage by 0.25%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #7410      +/-   ##
==========================================
- Coverage   55.07%   54.81%   -0.26%     
==========================================
  Files         588      587       -1     
  Lines       36760    36512     -248     
==========================================
- Hits        20245    20014     -231     
+ Misses      14417    14406      -11     
+ Partials     2098     2092       -6     

contrib/devtools/proto-tools-installer.sh Outdated Show resolved Hide resolved
@alessio
Copy link
Contributor

alessio commented Sep 30, 2020

@robert-zaremba dixit:

This doesn't solve anything. It just prints the message, and gogo/protobuf is already checked in go.mod, so this is noop.

Those lines remove pushd/popd calls, which are seemingly unnecessary. I agree that the comment should be removed though.

@robert-zaremba
Copy link
Collaborator

So, the whole command (f_install_protoc_gen_gocosmos) doesn't make sense because it doesn't fix any dependency

  1. github.com/regen-network/cosmos-proto/protoc-gen-gocosmos is a binary dependency for protoc. github.com/regen-network/cosmos-proto/ version is already fixed in go.mod.
  2. we should avoid running go get at all kind of setup scritps. We should use go get only when we add a new dependency or when we want to upgrade one.
  3. Go modules were designed specifically for this use-cases - to encapsulate all dependencies on go packages.

Go modules can be used to run binaries. Just use go run package/to/binary and we will run a binary (eg go run github.com/regen-network/cosmos-proto/protoc-gen-gocosmos).

Howe however here we have more delicate problem. Instead of us running the binary, it's protoc, which doesn't understand Go modules.

The ideal solution would be to:

  1. force go module to install binary in a local folder. Maybe with go vendor? Or maybe we can tweak GOBIN to make sure we will not collide with system wide installations.

  2. Then we can tweak PATH before running protoc

     PATH="./bin:$PATH" protoc ...
    

@alessio
Copy link
Contributor

alessio commented Sep 30, 2020

Maybe with go vendor?

No thanks. Using go vendor just to go install stuff does not sound super clever.

Or maybe we can tweak GOBIN to make sure we will not collide with system wide installations.

No thanks. GOBIN breaks cross-compilation and should not be used.

The root of all evils here still lies with the absence of a global go install command that does not touch modules go.mod files.

force go module to install binary in a local folder.

This is perhaps the best idea.

I'm still in favour of installing and using all these tools from some sort of devtools container in order to guaranteee reproducibility and ease of installation. @marbar3778 any ideas?

@robert-zaremba
Copy link
Collaborator

force go module to install binary in a local folder.

This is perhaps the best idea.

I'm not aware about any other way to do it without setting GOBIN.

@robert-zaremba
Copy link
Collaborator

robert-zaremba commented Sep 30, 2020

BTW: there are more people who has same problem: golang/go#32504

Ultimately, what I would love to see is that if my coworker git-cloned my project that depended on other main packages such as github.com/golang/protobuf/protoc-gen-go, they would be able to get the precise version that I intended to use protoc-gen-go with.

@robert-zaremba
Copy link
Collaborator

So, if we don't have any other solution I'm also for removing this script at all and encapsulate all protobuf dependencies in a docker container.

(same @amaurymartiny , @aaronc , @anilcse , @ethanfrey ....)

@robert-zaremba
Copy link
Collaborator

robert-zaremba commented Sep 30, 2020

(sorry, I missed the button ;) )

@alessio
Copy link
Contributor

alessio commented Sep 30, 2020

I'm not aware about any other way to do it without setting GOBIN.

GOBIN is unnecessary because the binary default installation directory is $GOPATH/bin. If you set GOBIN explicitly though, things change. I've commented on this subject multiple times, we've removed the mention of GOBIN from docs and instructions long time ago.

BTW: there are more people who has same problem: golang/go#32504

Yes. It's known limitation of go modules.

So, if we don't have any other solution I'm also for removing this script at all and encapsulate all protobuf dependencies in a docker container.

Yep - @marbar3778 was working on that IIRC?

@robert-zaremba
Copy link
Collaborator

GOBIN is unnecessary because the binary default installation directory is $GOPATH/bin. If you set GOBIN explicitly though, things change.

Exactly, this is what I meant: to pin GOBIN to a local directory, eg: GOBIN=./bin

@ethanfrey
Copy link
Contributor

ethanfrey commented Sep 30, 2020

So, if we don't have any other solution I'm also for removing this script at all and encapsulate all protobuf dependencies in a docker container.

💯 for this

The Dockerfile can/should be in the cosmos-sdk/devtools directory but trying to auto-gen code without locked versions between dev environments is chaos.

@alexanderbez
Copy link
Contributor

dkr++

Copy link
Collaborator

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me. Only diff is staking

@amaury1093
Copy link
Contributor Author

Are we okay to merge this temporary fix while waiting for the Docker solution (tracked here: #7332) ?

cc @robert-zaremba @alessio

@amaury1093 amaury1093 added the A:automerge Automatically merge PR once all prerequisites pass. label Oct 1, 2020
@mergify mergify bot merged commit 22b47f4 into master Oct 1, 2020
@mergify mergify bot deleted the am-proto-gen branch October 1, 2020 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:automerge Automatically merge PR once all prerequisites pass.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants