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

cmd/go: relative replacements in a workspace are not resolved relative to their go.mod files #51204

Closed
jezell opened this issue Feb 15, 2022 · 3 comments
Labels
FrozenDueToAge GoCommand cmd/go NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Milestone

Comments

@jezell
Copy link

jezell commented Feb 15, 2022

What version of Go are you using (go version)?

1.18beta2

Does this issue reproduce with the latest release?

What did you do?

Checkout the following repo:

https://github.com/jezell/gosync

run go work sync

What did you expect to see?

expect the command to complete successfully

What did you see instead?

go: conflicting replacements for example.com/test:
	../test
	../../test
use "go work edit -replace example.com/test=[override]" to resolve

Suggested Fix

It appears that when checking for replacement conflicts, go work sync does not resolve relative replacement paths. While this may work for flat workspaces, this causes problems when module replacements are used within sub folders. Perhaps go work sync should resolve relative paths to absolute paths before performing its check for conflicts so that when two replacements point to exactly the same place the command doesn't fail.

@bcmills bcmills added GoCommand cmd/go NeedsFix The path to resolution is known, but the work has not been done. labels Feb 15, 2022
@bcmills bcmills added this to the Go1.18 milestone Feb 15, 2022
@bcmills
Copy link
Member

bcmills commented Feb 15, 2022

FWIW, I don't think this is specific to go work sync. Investigating.

@bcmills bcmills changed the title go work sync does not properly resolve paths when checking for replace conflicts cmd/go: relative replacements in a workspace are not resolved relative to their go.mod files Feb 15, 2022
@bcmills bcmills self-assigned this Feb 15, 2022
@gopherbot
Copy link

Change https://go.dev/cl/385994 mentions this issue: cmd/go: in workspace mode, resolved replacements relative to their go.mod files

@bcmills
Copy link
Member

bcmills commented Feb 15, 2022

Marking as release-blocker: I have a fix out for review and passing tests, and the sort of replace that triggers this bug is likely to occur in real multi-module repos.

@rsc rsc unassigned bcmills Jun 22, 2022
@golang golang locked and limited conversation to collaborators Jun 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge GoCommand cmd/go NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Projects
None yet
Development

No branches or pull requests

3 participants