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

Initial install in new env #88

Closed
nalbury opened this issue May 25, 2021 · 3 comments
Closed

Initial install in new env #88

nalbury opened this issue May 25, 2021 · 3 comments

Comments

@nalbury
Copy link

nalbury commented May 25, 2021

First off, thank you for this tool!

I was curious what the best practice is for installing the initial bingo binary for a project with an existing bingo configuration?

My first thought (and the process described in the docs) was to just go get github.com/bwplotka/bingo in my project. This of course works, but subsequent go mod tidy runs (somewhat obviously) remove bingo from my project's go.mod file since it's not actually used in code anywhere.

I saw in the docs that you can use bingo to manage bingo itself :-) but when I go build using the module file in my project I get:

go: github.com/bwplotka/bingo@v0.4.3: missing go.sum entry; to add it:
        go mod download github.com/bwplotka/bingo

Which I think is the same issue mentioned here, as I am also using go 1.16.

In the interim I've been installing bingo as an initial OS dependency w/ the recently added go install tool which works without issue and avoids adding extra entries to my go.mod file:

go install github.com/bwplotka/bingo@v0.4.3

Apologies in advance if this is just a duplicate GitHub issue, but was wondering if I was maybe just thinking about this all wrong, and if so, if there's a documentation improvement I could submit to assist others.

Thanks!

@bwplotka
Copy link
Owner

bwplotka commented May 30, 2021

Hmm, interesting.

No bingo action should touch your application go.mod. Let's investigate, thanks for reporting!

Let's bring similar details here:

image

This of course works, but subsequent go mod tidy runs (somewhat obviously) remove bingo from my project's go.mod file since it's not actually used in code anywhere.

That's fine, as you already should have the binary installed on your system, so you can use it. Use bingo to manage bingo only if you would like to pin version of it to the system (good practice).

Let's update the installation method to go install github.com/bwplotka/bingo that is useful that it does not touch go.mod, but both ways should work.

On my side with Go 1.16, I can't reproduce any of those errors:

➜  godoc git:(main) ✗ go get github.com/bwplotka/bingo
go: downloading github.com/bwplotka/bingo v0.4.3
go get: added github.com/bwplotka/bingo v0.4.3
➜  godoc git:(main) ✗ go version
go version go1.16.3 linux/amd64
➜  godoc git:(main) ✗ bingo version
v0.4.3
➜  godoc git:(main) ✗ bingo get golang.org/x/tools/cmd/godoc
➜  godoc git:(main) ✗ bingo get -l github.com/bwplotka/bingo

(Fresh env)

@nalbury
Copy link
Author

nalbury commented May 30, 2021

Interesting so I think there were a few things going on specific to the project I was working on (part of the reason I want to use bingo :-), as I was just able to successfully install command line dependencies on a test project I spun up to repro this.

The only real deviation from the docs I made was using go install github.com/bwplotka/bingo@v0.4.3 to make sure that bingo was both installed and not added to my projects go.mod.

From my workstation:

➜  bingo-test git:(main) ✗ go install github.com/bwplotka/bingo@v0.4.3
go: downloading github.com/bwplotka/bingo v0.4.3
go: downloading mvdan.cc/sh/v3 v3.2.4
go: downloading golang.org/x/sys v0.0.0-20201029080932-201ba4db2418
go: downloading golang.org/x/term v0.0.0-20191110171634-ad39bd3f0407
go: downloading golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9
➜  bingo-test git:(main) ✗ bingo get github.com/spf13/cobra/cobra
Bingo not used before here, creating directory for pinned modules for you at .bingo
➜  bingo-test git:(main) ✗ bingo get -l github.com/bwplotka/bingo
➜  bingo-test git:(main) ✗ tree .bingo 
.bingo
├── README.md
├── Variables.mk
├── bingo.mod
├── cobra.mod
├── go.mod
└── variables.env

Then after using cobra to build a cli scaffold, I mounted that code into a blank golang:1.16-buster container and ran

root@500df05675fc:/go# cd /bingo-test/
root@500df05675fc:/bingo-test# go install github.com/bwplotka/bingo@v0.4.3
go: downloading github.com/bwplotka/bingo v0.4.3
go: downloading github.com/efficientgo/tools/core v0.0.0-20210201220623-8118984754c2
go: downloading github.com/oklog/run v1.1.0
go: downloading github.com/pkg/errors v0.9.1
go: downloading golang.org/x/mod v0.3.0
go: downloading github.com/Masterminds/semver v1.5.0
go: downloading mvdan.cc/sh/v3 v3.2.4
go: downloading golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898
go: downloading golang.org/x/term v0.0.0-20191110171634-ad39bd3f0407
go: downloading golang.org/x/sys v0.0.0-20201029080932-201ba4db2418
go: downloading golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9
root@500df05675fc:/bingo-test# bingo get -l
root@500df05675fc:/bingo-test# ls -la `which cobra`
lrwxrwxrwx 1 root root 20 May 30 15:48 /go/bin/cobra -> /go/bin/cobra-v1.1.3
root@500df05675fc:/bingo-test# ls -la `which bingo`
lrwxrwxrwx 1 root root 20 May 30 15:48 /go/bin/bingo -> /go/bin/bingo-v0.4.3

This is great! and I think understanding it this way (treating bingo like pip or bundle) goes a long way to clearing up my usage issues.

The only remaining question I have is around using go build to install tools without bingo as mentioned here in the documentation. The usage pattern above works great, but the idea of using bingo on my workstation to version my command line tools, and leaving it out of containerized envs in favor of using go build is an intriguing one to me. When attempting this I get the previously mentioned missing go.sum error:

root@b6974605b86c:/bingo-test# go build -modfile .bingo/bingo.mod -o=$GOBIN/bingo-v0.4.3
go: github.com/bwplotka/bingo@v0.4.3: missing go.sum entry; to add it:
	go mod download github.com/bwplotka/bingo

This appears to be a new behavior in go 1.16 and appears to have been patched in bingo get here. I'm going to see if I can replicate the series of go cmds/flags that PR is running, but any guidance is much appreciated. Happy to submit a PR for the README once I get it all figured it out.

Thanks!

@bwplotka
Copy link
Owner

I think the documentation should give you clue now:

go build -mod=mod -modfile .bingo/<tool>.mod -o=$GOBIN/<tool>-<version>

-mod=mod is what is required (:

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

2 participants