bwplotka / bingo

Like `go get` but for Go tools! CI Automating versioning of Go binaries in a nested, isolated Go modules.
Apache License 2.0
340 stars 29 forks source link

Fails to install package with local `replace` directives and multiple modules #150

Open douglascamata opened 6 months ago

douglascamata commented 6 months ago

bingo version output:

v0.9

go version output:

go version go1.21.5 darwin/arm64

What happened:

Tried to install the latest po-lint package with bingo get -v -l github.com/prometheus-operator/prometheus-operator/cmd/po-lint@latest.

What you expected to happen:

To have po-lint installable, even though it has a few replace clauses.

How to reproduce it (as minimally and precisely as possible):

bingo get -v -l github.com/prometheus-operator/prometheus-operator/cmd/po-lint@latest

Logs (use bingo get -v <thing you do> for verbose output):

Click to see lots of logs! ``` getting target github.com/prometheus-operator/prometheus-operator/cmd/po-lint@latest (module ) exec 'go mod init -modfile=/Users/doolivei/code/obsctl-reloader-rules-checker/.bingo/po-lint-e.tmp.mod _' exec 'go get -modfile=/Users/doolivei/code/obsctl-reloader-rules-checker/.bingo/po-lint-e.tmp.mod -d github.com/prometheus-operator/prometheus-operator/cmd/po-lint@latest' exec 'go env GOMODCACHE' resolveInGoModCache: /Users/doolivei/go/pkg/mod/cache/download/github.com/prometheus-operator/prometheus-operator/cmd/po-lint/@v directory does not exists resolveInGoModCache: /Users/doolivei/go/pkg/mod/cache/download/github.com/prometheus-operator/prometheus-operator/cmd/@v directory does not exists resolveInGoModCache: Found /Users/doolivei/go/pkg/mod/cache/download/github.com/prometheus-operator/prometheus-operator/@v directory exec 'go env GOPATH' exec 'go mod init -modfile=/Users/doolivei/code/obsctl-reloader-rules-checker/.bingo/po-lint.tmp.mod _' exec 'go list -modfile=/Users/doolivei/code/obsctl-reloader-rules-checker/.bingo/po-lint.tmp.mod -mod=mod -f={{.Name}} github.com/prometheus-operator/prometheus-operator/cmd/po-lint' Error: get: po-lint.mod: getting github.com/prometheus-operator/prometheus-operator/cmd/po-lint@latest: install: : go: github.com/prometheus-operator/prometheus-operator/cmd/po-lint imports github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1: github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring@v0.70.0: replacement directory ./pkg/apis/monitoring does not exist go: github.com/prometheus-operator/prometheus-operator/cmd/po-lint imports github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1alpha1: github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring@v0.70.0: replacement directory ./pkg/apis/monitoring does not exist go: github.com/prometheus-operator/prometheus-operator/cmd/po-lint imports github.com/prometheus-operator/prometheus-operator/pkg/admission imports github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1beta1: github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring@v0.70.0: replacement directory ./pkg/apis/monitoring does not exist go: github.com/prometheus-operator/prometheus-operator/cmd/po-lint imports github.com/prometheus-operator/prometheus-operator/pkg/admission imports github.com/prometheus-operator/prometheus-operator/pkg/operator imports github.com/prometheus-operator/prometheus-operator/pkg/informers imports github.com/prometheus-operator/prometheus-operator/pkg/client/informers/externalversions: github.com/prometheus-operator/prometheus-operator/pkg/client@v0.70.0: replacement directory ./pkg/client does not exist go: github.com/prometheus-operator/prometheus-operator/cmd/po-lint imports github.com/prometheus-operator/prometheus-operator/pkg/admission imports github.com/prometheus-operator/prometheus-operator/pkg/operator imports github.com/prometheus-operator/prometheus-operator/pkg/informers imports github.com/prometheus-operator/prometheus-operator/pkg/client/versioned: github.com/prometheus-operator/prometheus-operator/pkg/client@v0.70.0: replacement directory ./pkg/client does not exist : error while running command 'go get -modfile=/Users/doolivei/code/obsctl-reloader-rules-checker/.bingo/po-lint.tmp.mod -d github.com/prometheus-operator/prometheus-operator/cmd/po-lint@v0.70.0'; err: exit status 1 Usage: bingo get [flags] [[@version1 or none,version2,version3...]] Examples: bingo get github.com/fatih/faillint bingo get github.com/fatih/faillint@latest bingo get github.com/fatih/faillint@v1.5.0 bingo get github.com/fatih/faillint@v1.1.0,v1.5.0 bingo get github.com/fatih/faillint@none // this will be deleted Options: --go string Path to the go command. (default "go") -h, --help help for get --insecure Use -insecure flag when using 'go get' -l, --link If enabled, bingo will also create soft link called that links to the current - binary. Use Variables.mk and variables.env if you want to be sure that what you are invoking is what is pinned. -n, --name string The -n flag instructs to get binary and name it with given name instead of default, so the last element of package directory. Allowed characters [A-z0-9._-]. If -n is used and no package/binary is specified, bingo get will return error. If -n is used with existing binary name, copy of this binary will be done. Cannot be used with -r -r, --rename string The -r flag instructs to get existing binary and rename it with given name. Allowed characters [A-z0-9._-]. If -r is used and no package/binary is specified or non existing binary name is used, bingo will return error. Cannot be used with -n. -t, --timeout uint The maximum time (in minutes) to wait for each go command before killing it. Set this flag to 0 to indefinitely wait on them. (default 5) Global Flags: -m, --moddir string Directory where separate modules for each binary will be maintained. Feel free to commit this directory to your VCS to bond binary versions to your project code. If the directory does not exist bingo logs and assumes a fresh project. (default ".bingo") -v, --verbose Print more get: po-lint.mod: getting github.com/prometheus-operator/prometheus-operator/cmd/po-lint@latest: install: : go: github.com/prometheus-operator/prometheus-operator/cmd/po-lint imports github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1: github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring@v0.70.0: replacement directory ./pkg/apis/monitoring does not exist go: github.com/prometheus-operator/prometheus-operator/cmd/po-lint imports github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1alpha1: github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring@v0.70.0: replacement directory ./pkg/apis/monitoring does not exist go: github.com/prometheus-operator/prometheus-operator/cmd/po-lint imports github.com/prometheus-operator/prometheus-operator/pkg/admission imports github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1beta1: github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring@v0.70.0: replacement directory ./pkg/apis/monitoring does not exist go: github.com/prometheus-operator/prometheus-operator/cmd/po-lint imports github.com/prometheus-operator/prometheus-operator/pkg/admission imports github.com/prometheus-operator/prometheus-operator/pkg/operator imports github.com/prometheus-operator/prometheus-operator/pkg/informers imports github.com/prometheus-operator/prometheus-operator/pkg/client/informers/externalversions: github.com/prometheus-operator/prometheus-operator/pkg/client@v0.70.0: replacement directory ./pkg/client does not exist go: github.com/prometheus-operator/prometheus-operator/cmd/po-lint imports github.com/prometheus-operator/prometheus-operator/pkg/admission imports github.com/prometheus-operator/prometheus-operator/pkg/operator imports github.com/prometheus-operator/prometheus-operator/pkg/informers imports github.com/prometheus-operator/prometheus-operator/pkg/client/versioned: github.com/prometheus-operator/prometheus-operator/pkg/client@v0.70.0: replacement directory ./pkg/client does not exist : error while running command 'go get -modfile=/Users/doolivei/code/obsctl-reloader-rules-checker/.bingo/po-lint.tmp.mod -d github.com/prometheus-operator/prometheus-operator/cmd/po-lint@v0.70.0'; err: exit status 1 ```

Anything else we need to know:

The replace clauses in po-lint are replacing external packages with ones that are local to the po-lint repo. These packages are within other Go modules that live in the same repo (github.com/prometheus-operator/prometheus-operator/pkg/client and github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring).

saswatamcode commented 6 months ago

Hmm, I think go install also fails if the module being installed has replace/exclude directives,

$ go install github.com/prometheus-operator/prometheus-operator/cmd/po-lint@latest
go: downloading github.com/prometheus-operator/prometheus-operator v0.70.0
go: github.com/prometheus-operator/prometheus-operator/cmd/po-lint@latest (in github.com/prometheus-operator/prometheus-operator@v0.70.0):
    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.

So then isn't it expected that bingo would also not be able to install it either? Or am I missing something? 🤔

douglascamata commented 6 months ago

@saswatamcode Bingo's README says it doesn't care about these directives:

Works with all buildable Go projects, including pre Go modules and complex projects with complex directives like replace, retract or exclude statements. (e.g Prometheus)

saswatamcode commented 6 months ago

Ack, you're right! I guess there is some bug with local replace directives then!

bwplotka commented 1 month ago

Can you add those replace directives in po-lint.mod after failed bingo get? I think they should be done automatically, but that might have failed for some reason?