-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: can't use "replace" directive on Windows #32215
Comments
/cc @bcmills |
@hach-que is there a If not, that might explain the error. If the target of a Alternatively, within the Go code of However, maybe there is something else going on that is causing that error. If it is still a question as to the cause:
One side note: multi-module repos are generally rare. The simplest and most common structure is to instead have a single Russ Cox commented in #26664:
Here is a recent example of how multi-module repos can go a bit off the rails: ugorji/go#299 Is there a particular reason for |
This is our internal monorepo for all our microservices. We have a few
libraries that are copied out to each microservice.
Right now we use relative paths everywhere to access these libraries, but I
wanted to test the new module system since my understanding is the old
stuff is going away. And when it does, less external libraries will support
non-module usage (we already have a few libraries we have to wrangle in our
Dockerfiles to make them work with the old way) and then eventually at some
point relative package paths will stop working entirely in a newer Go
version.
The config folder did indeed have it's own go.mod file, and it had the name
`github.com/networknext/next/services/publisher/config`. The references
inside publisher were also to that name. I can double check this later
today.
I'm pretty sure this is a case of the replace directive just not handling
Windows paths correctly. It looks like it's converting the relative path
into an absolute path, and then trying to normalize it to some Unix style
format, which then causes it to not find the actual go.mod file that
resides on disk.
…On Fri, May 24, 2019, 11:45 AM thepudds ***@***.***> wrote:
@hach-que <https://github.com/hach-que> is there a go.mod file located at
C:\Users\June_Rhodes\Documents\Projects\next\services\publisher\config?
If not, that might explain the error. If the target of a replace
statement is a filesystem path, that filesystem path must point to a
directory with a go.mod.
Alternatively, within the Go code of
github.com/networknext/next/services/publisher, are there any import
"./config" statements? If so, relative import paths as no longer allowed
<https://github.com/golang/go/wiki/Modules#do-modules-work-with-relative-imports-like-import-subdir>
with modules.
However, maybe there is something else going on that is causing that error.
If it is still a question as to the cause:
1. What does the module line say for the ./config/go.mod file?
2. What do the import paths say in the
github.com/networknext/next/services/publisher to import the config
module?
One side note: multi-module repos are generally rare. The simplest and
most common structure is to instead have a single go.mod, and locate that
single go.mod at the root of the repository.
Russ Cox commented in #26664 <#26664>:
For all but power users, you probably want to adopt the usual convention
that one repo = one module. It's important for long-term evolution of code
storage options that a repo can contain multiple modules, but it's almost
certainly not something you want to do by default.
Here is a recent example of how multi-module repos can go a bit off the
rails: ugorji/go#299 <ugorji/go#299>
Is there a particular reason for ./config to be a separate module?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#32215?email_source=notifications&email_token=AAD3H6XSOQLW273SCO62MWTPXAZTZA5CNFSM4HPKB46KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWGISWQ#issuecomment-495749466>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAD3H6UI64MQZQTQFNHBMS3PXAZTZANCNFSM4HPKB46A>
.
|
Is the If so, the error message you are seeing seems to line up with #26645, where one example from there includes:
which is at least somewhat similar to:
|
Hmm, well I just tried to put together an example to replicate, and the example works fine on Windows: So I must have done something wrong when I was changing the way the library was imported. I'll take another look at the code in our monorepo tonight to see what's wrong with it. |
Thanks, let us know what you find. At the very least it seems like we should produce a better error message, whenever we can figure out what's causing this error message to begin with. |
Timed out in state WaitingForInfo. Closing. (I am just a bot, though. Please speak up if this is a mistake or you have the requested information.) |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, it happens on
go version go1.12.5 windows/amd64
.What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
The directory structure looks like this:
I'm trying to import the config subdirectory as a module.
What did you expect to see?
I expected it to build successfully.
What did you see instead?
It complains about the path "/C/Users/June_Rhodes/Documents/Projects/next/services/publisher/config" not existing.
The text was updated successfully, but these errors were encountered: