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

The go.mod file for the module providing named packages contains one or more replace directives. #3873

Open
lifestreamy opened this issue Nov 13, 2022 · 7 comments

Comments

@lifestreamy
Copy link

Running
go install github.com/linuxkit/linuxkit/src/cmd/linuxkit@latest
in Windows powershell results in

go: github.com/linuxkit/linuxkit/src/cmd/linuxkit@latest (in github.com/linuxkit/linuxkit/src/cmd/linuxkit@v0.0.0-20221110081417-aa2482123637):
        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.

image

@Petrichia
Copy link

In fedora 36 I have the same issue.

@deitch
Copy link
Collaborator

deitch commented Nov 25, 2022

I don't understand why this is an issue? github.com/linuxkit/linuxkit/src/cmd/linuxkit is the main module.

@Petrichia
Copy link

Petrichia commented Nov 25, 2022

I don't really know. I test it with go version 1.18, just in case. And the issue remains.
I test it with different go version because I had issues with go1.19, when trying to install linuxkit with make local. It was beacuse go1.19 doesn't let you execute go get if you don't executed it where a go.mod is located.

@Petrichia
Copy link

Petrichia commented Nov 25, 2022

In Go-issue#40276, on section Why can't module replace directives be used? seems to explain why replace directives should report an error with go install.

@Nosmoht
Copy link

Nosmoht commented Jan 27, 2023

@deitch

it's an issue because it's mentioned in the docs to do so:

If you already have go installed you can use go install github.com/linuxkit/linuxkit/src/cmd/linuxkit@latest to install the linuxkit tool.

So after all linuxkit is not installed after executing the command. People just expect to have a working docu ;)

@deitch
Copy link
Collaborator

deitch commented Jan 29, 2023

Wrapping my head around this, so:

  • I cannot use replace directives in my go.mod unless I am actually installing from inside the directory: cd src/cmd/linuxkit && go install .
  • Outside of it does not work: go install github.com/linuxkit/linuxkit/src/cmd/linuxkit will not work if the go.mod has replace directives; I must either have no such directives, or explicitly clone the repo, cd into it, and then go install .

and, of course, replace directives are ignored in transient dependencies, only in the main module... but I cannot use them there if I want to do a straight go install from anywhere.

Is that about right? That is a surprisingly user unfriendly process. "Use replace directives if you need to lock to a specific version or alias, but it won't work for anything transient and it won't work if your module is just included in another module and it will break if you use go install." So when is it useful?

FWIW, I am trying to get rid of those replace directives. I got rid of most of them, just one left, hopefully to be gotten rid of soon enough.

@deitch
Copy link
Collaborator

deitch commented Feb 16, 2023

See #3912

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

4 participants