Can't install profilecli with 'go install'
Describe the bug
I wanted to install profilecli locally, and the first way I thought of was to use go install, but that failed because of the replace directives.
To Reproduce
Steps to reproduce the behavior:
-
$ go install github.com/grafana/phlare/cmd/profilecli@latest go: downloading github.com/grafana/phlare v0.5.1 go: github.com/grafana/phlare/cmd/profilecli@latest (in github.com/grafana/[email protected]): 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.
Expected behavior
I expected that command to succeed...
Environment
- Infrastructure: local (desktop)
- Deployment tool: n/a
Additional Context
A simple workaround is to just download the pre-built binaries from the release page
Could you please try go install github.com/grafana/phlare/cmd/profilecli? It works for me.
$ go install github.com/grafana/phlare/cmd/profilecli@latest go: downloading github.com/grafana/phlare v0.5.1 go: github.com/grafana/phlare/cmd/profilecli@latest (in github.com/grafana/[email protected]): 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.
This is a restriction when you have version suffixes.
in a clean environment (golang:1.20 Docker image):
root@dfc43b015469:~# go install github.com/grafana/phlare/cmd/profilecli
go: 'go install' requires a version when current directory is not in a module
Try 'go install github.com/grafana/phlare/cmd/profilecli@latest' to install the latest version
In other words - @latest is required in order to compile/install a binary for general use
in a clean environment (
golang:1.20Docker image):root@dfc43b015469:~# go install github.com/grafana/phlare/cmd/profilecli go: 'go install' requires a version when current directory is not in a module Try 'go install github.com/grafana/phlare/cmd/profilecli@latest' to install the latest versionIn other words -
@latestis required in order to compile/install a binary for general use
Oops. Sorry for the unclear. Could you please try cloning the repo and try go install github.com/grafana/phlare/cmd/profilecli in your repo directory? I think it would work.
@cyriltovena As this is a workaround. I think we can close this issue now.
I just tried to go install github.com/grafana/pyroscope/cmd/profilecli@latest and now it's erroring because there are replace lines in the go.mod:
$ go install github.com/grafana/pyroscope/cmd/profilecli@latest
go: github.com/grafana/pyroscope/cmd/profilecli@latest (in github.com/grafana/[email protected]):
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.
I came to file a new issue but found this one that I'd forgotten about 😅