-
Notifications
You must be signed in to change notification settings - Fork 18k
Can't build after a private module has moved #35990
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
Comments
When you change the import path, you must also change the path declared in the Replace
with
and it should be fine without a |
You mean in the module I'm trying to import? The module is a mirror of a module internal to another department. We used to have access to it, but now have to use the mirror. They export to this repo whenever they're stable, so I have no control over its I just want to import and use it. |
Ok. In that case, you do need something like
and to import via the old import path. Are you sure the paths in your |
OK, I set this in my go.mod:
And my imports now look like this:
Doing a go list:
Doing a go build:
|
You need a real version (or a real commit hash) on the right-hand side of that |
There are no tags in that repository. What would I put in? |
A commit hash, or |
OK, putting in
So it's not able to see the repository for some reason? |
You still need to set |
Ah right, that worked :) |
All set then? (Can we close this issue?) FYI @tbpg @jadekler @jayconrod: this workflow might be something to bear in mind for documentation examples. |
Yup that works, thanks. Although for future I think the error messages need tweaking. It was impossible on my own to figure out what was wrong. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputIssue Description
I'm trying to build a project that includes a private module whose location has changed.
In my source files, I changed
import "github.com/oldwaycorp/mysupermodule"
toimport "github.com/newhotnessio/mysupermodule"
, then attempted to build:According to https://golang.org/doc/faq#git_https I should add this to
.gitconfig
:Try building again:
Searching around online, I find this: https://medium.com/mabar/today-i-learned-fix-go-get-private-repository-return-error-reading-sum-golang-org-lookup-93058a058dd8
Apparently, I need to use
GOPRIVATE
:I'm not sure where it's getting
oldwaycorp
from.grep -r oldwaycorp
returns no results.After some digging around in various blogs and reddit, I tried adding this to
go.mod
:Then attempted a build:
Nope, that didn't work. More googling finds #35723
Looks like I'm also supposed to use the OLD import path, not the new one. I change my source files back to use the old import path ad try again:
Now it's trying to fetch from the old repository, which of course it can't because it's supposed to be fetching from the new repository. Isn't the
replace
directive supposed to redirect to the new repository?Aside from the terrible error messaging in all of this, I'm still left with an unbuildable codebase. How should I handle a private repo that has moved?
The text was updated successfully, but these errors were encountered: