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

diff: latest release version still has old module path #33

Closed
dmitshur opened this Issue Apr 6, 2019 · 11 comments

Comments

Projects
None yet
5 participants
@dmitshur
Copy link
Contributor

dmitshur commented Apr 6, 2019

The import path of this package has changed in PR #30. /cc @sqs

However, the latest released version (v0.5.0) still has the old module path in its go.mod file:

https://github.com/sourcegraph/go-diff/blob/v0.5.0/go.mod#L1

As a result, trying to install the latest version of this package in module mode fails:

$ cd $(mktemp -d)

$ go mod init m
go: creating new go.mod: module m

$ go get github.com/sourcegraph/go-diff/diff
go: finding github.com/sourcegraph/go-diff/diff latest
go: github.com/sourcegraph/go-diff@v0.5.0: parsing go.mod: unexpected module path "sourcegraph.com/sourcegraph/go-diff"
go: error loading module requirements

$ echo $?
1

This can be fixed this by making a new release version (perhaps v0.5.1) that contains the new module path in the go.mod file.

@dmitshur dmitshur changed the title diff: latest release version still has old import path diff: latest release version still has old module path Apr 6, 2019

@sqs

This comment has been minimized.

Copy link
Member

sqs commented Apr 7, 2019

Thanks for reporting this. I just pushed v0.5.1.

xq:~/src/sourcegraph.com/sourcegraph/go-diff $ cd $(mktemp -d)
xq:/tmp/tmp.1x6ATreARY $ go mod init m
go: creating new go.mod: module m
xq:/tmp/tmp.1x6ATreARY $ go get github.com/sourcegraph/go-diff/diff
go: finding github.com/sourcegraph/go-diff/diff latest
go: finding github.com/sourcegraph/go-diff v0.5.1
go: downloading github.com/sourcegraph/go-diff v0.5.1
go: extracting github.com/sourcegraph/go-diff v0.5.1

@sqs sqs closed this Apr 7, 2019

@dmitshur

This comment has been minimized.

Copy link
Contributor Author

dmitshur commented Apr 7, 2019

Thanks for the quick fix.

@ppapapetrou76

This comment has been minimized.

Copy link

ppapapetrou76 commented Apr 8, 2019

Hey @sqs I think it's still happening on 0.5.1
go: sourcegraph.com/sourcegraph/go-diff@v0.5.1: parsing go.mod: unexpected module path "github.com/sourcegraph/go-diff"

If I set the module dependency to direct like this github.com/sourcegraph/go-diff v0.5.1 before the module that has a dependency to it it's fine

@dewey

This comment has been minimized.

Copy link

dewey commented Apr 8, 2019

@ppapapetrou76 as you said you have an indirect dependency it's probably some dependency of yours that pulls go-diff in with a wrong import path. In this case you could rewrite the path to the new one in your go.mod file like:

go mod edit -replace sourcegraph.com/sourcegraph/go-diff@latest=github.com/sourcegraph/go-diff@latest

@ppapapetrou76

This comment has been minimized.

Copy link

ppapapetrou76 commented Apr 8, 2019

Indeed the root cause it's here golangci/golangci-lint#487 😄
I will apply your suggestion while waiting for the PR merge

TY!!

@sqs

This comment has been minimized.

Copy link
Member

sqs commented Apr 8, 2019

Sorry for the problems caused, @ppapapetrou76. Just checking, it sounds like your problem is solved (or wil be solved when that PR is merged), right?

@rameshvk

This comment has been minimized.

Copy link

rameshvk commented Apr 9, 2019

I did the replace trick suggested before and now I get:

go: github.com/sourcegraph/go-diff@v0.5.1 used for two different module paths (github.com/sourcegraph/go-diff and sourcegraph.com/sourcegraph/go-diff)

Not really looking for a resolution as the large set of issues I faced with go mod have convinced me to abandon go.mod until after it matures and is well supported. This is mostly to note that the replace trick may not always work.

@dmitshur

This comment has been minimized.

Copy link
Contributor Author

dmitshur commented Apr 9, 2019

@rameshvk Sorry to hear you've had a bad experience with modules. If you'd like, feel free to /cc me on an issue in the repository where you ran into the problem with more information, and I can take a look. Perhaps it's been fixed for Go 1.13 already, and if not, we want to make sure it does.

The summary of the situation here is that version v0.5.0 of go-diff can only be used at the module path sourcegraph.com/sourcegraph/go-diff, and versions v0.5.1 (and newer) can only be used at the module path github.com/sourcegraph/go-diff (because that's the version where its module path changed).

The following replace directive can be used in the main module to replace any incorrect module versions (in dependencies that haven't been updated yet) with a working one:

replace sourcegraph.com/sourcegraph/go-diff => sourcegraph.com/sourcegraph/go-diff v0.5.0

And/or:

replace github.com/sourcegraph/go-diff => github.com/sourcegraph/go-diff v0.5.1
@rameshvk

This comment has been minimized.

Copy link

rameshvk commented Apr 9, 2019

Doing that replace gives me this error:

go: errors parsing go.mod: go.mod:63: replacement module without version must be directory path (rooted or starting with ./ or ../)

I also tried cloning the package locally (which is actually what I'd prefer) but that had a different set of errors.

I find that most issues I run into have been reported (like this) -- it is just that the set of workarounds does not seem like things I can maintain. I suspect when all upstream packages migrate to go.mod, much of my pain will go away and I can then migrate over too.

@dmitshur

This comment has been minimized.

Copy link
Contributor Author

dmitshur commented Apr 9, 2019

My mistake, I didn't test the exact replace directive I suggested. Updated my post above to provide a better suggestion.

@rameshvk Can you point me to a repository and a command I can run to reproduce your original problem? It'll be easier to diagnose this with more information.

That said, you're right, the experience should improve over time. Still, I'm happy to help with your problem if you'd like.

@rameshvk

This comment has been minimized.

Copy link

rameshvk commented Apr 9, 2019

Thanks for your help, that does work (though its not clear to me why go mod -replace wont do a blanket replace as that itself is a useful feature)

The repository I'm migrating is a dep of testmd and the only reason I'm migrating this is because I get an error downstream:

	imports github.com/tvastar/test
	imports gopkg.in/russross/blackfriday.v2: unknown import path "gopkg.in/russross/blackfriday.v2": cannot find module providing package gopkg.in/russross/blackfriday.v2
gopkg.in/russross/blackfriday.v2

I figured upgrading this to go.mod might help. Your help (thanks!) unblocked one issue but next up is that golangci-lint has an issue (which has been fixed but not released yet). I suppose I could go get a particular commit from golangci-lint but doing so seems to pollute my go.mod with package versions that are not tied to actual code dependencies but lint-tool dependencies. I wish I could just download all the things I need and commit them (sort of like vendor but with guarantees that build would break rather than auto-download something).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.