Dep: ctx.DetectProjectGOPATH: both C:\Work\src\github.com\F21\some_project are in the same GOPATH C:\Work\src\github.com\F21\some_project with Git Bash

Created on 20 Jun 2017  路  22Comments  路  Source: golang/dep

What version of Go (go version) and dep (git describe --tags) are you using?

Go 1.9-Beta1 and dep c79b048e07eccf76d323d4c2e88d7c6d72ea735f
Git is 2.13.1.windows.1

What dep command did you run?

I have a project with this structure

  • cmd

    • some_executable

    • main.go

  • some_package (imports the some_project package)
  • something.go (package is some_project)
$ dep init -v

What did you expect to see?

There should be no error and init should work correctly.

What did you see instead?

ctx.DetectProjectGOPATH: both C:\Work\src\github.com\F21\some_project and C:\Work\src\github.com\F21\some_project are in the same GOPATH C:/Work/

bug

Most helpful comment

If it helps, this is also happening to me on Windows. I can reproduce in a debugger by placing a lowercase drive letter in the working directory. For example, run dep init in a D:\go\src\myproject and setting the cwd to d:\go\src\myproject The following (in DetectProjectGOPATH() github.com\golangdep\context.go)

    if p.AbsRoot == p.ResolvedAbsRoot {
        return pGOPATH, perr
    }

condition fails because of case difference.

Drive letters should be also treated insensitive on Windows, as some tooling can mangle paths from different sources (for example, having naive scripts using the cygwin mounts /d/... converting to d:/...)

All 22 comments

@ibrasho i think we may have broken windows support :(

Git repro demonstrating the issue here: https://github.com/F21/dep-gopath-err

This error makes no sense. 馃槙

What's the value of GOPATH in Git Bash and the command prompt (echo %GOPATH%)?

@ibrasho In both Git Bash and CMD, the GOPATH are set to C:\Work. I confirmed this by echoing the respective GOPATH environment variable in each shell.

Copying from Slack:

@F21: I get the problem if I run it in Git bash in admin mode, but not in the cmd shell using cmder
in both shells, the GOPATH env var resolves to C:/work
seems to not work in git bash
whether git bash is being run as admin or not

ctx.DetectProjectGOPATH: both C:\Work\src\github.com\F21\some_project and C:\Work\src\github.com\F21\some_project are in the same GOPATH C:/Work/

This error message means the following values were set and detected:

Varible | Value
--- | ---
Project.AbsRoot | C:\Work\src\github.com\F21\some_project
Project.ResolvedAbsRoot | C:\Work\src\github.com\F21\some_project
Ctx.GOPATH | C:/Work/

This line in Ctx.DetectProjectGOPATH should have returned true on these values and returned the GOPATH with no error.

@F21 I would appreciate it if you have time to debug this further.

@ibrasho

Just tried this on my dev machine with git bash:

$ echo $GOPATH
D:\10-workspace\go

$ dep init
ctx.DetectProjectGOPATH: both D:\10-workspace\go\src\github.com\some_company\some_project and D:\10-workspace\go\src\github.com\some_company\some_project are in the same GOPATH D:/10-Workspace/go

Could you try running this gist and report what it outputs?

Running it in git bash:

$ go run main.go
absRoot: D:\10-workspace\go\src\github.com\F21\dep-gopath-err\cmd\something_else
resolvedAbsRoot: D:\10-workspace\go\src\github.com\F21\dep-gopath-err\cmd\something_else
absRoot == resolvedAbsRoot: false
GOPATHs: [D:\10-workspace\go]
trying to detect GOPATH for D:\10-workspace\go\src\github.com\F21\dep-gopath-err\cmd\something_else
        D:\10-workspace\go: true
trying to detect GOPATH for D:\10-workspace\go\src\github.com\F21\dep-gopath-err\cmd\something_else
        D:\10-workspace\go: true
detectProjectGOPATH: both D:\10-workspace\go\src\github.com\F21\dep-gopath-err\cmd\something_else and D:\10-workspace\go\src\github.com\F21\dep-gopath-err\cmd\something_else are in the same GOPATH D:\10-workspace\go

Running it in cmder/cmd

位 go run main.go
absRoot: D:\10-workspace\go\src\github.com\F21\dep-gopath-err\cmd\something_else
resolvedAbsRoot: D:\10-workspace\go\src\github.com\F21\dep-gopath-err\cmd\something_else
absRoot == resolvedAbsRoot: true
GOPATHs: [D:\10-workspace\go]
trying to detect GOPATH for D:\10-workspace\go\src\github.com\F21\dep-gopath-err\cmd\something_else
        D:\10-workspace\go: true
GOPATH: D:\10-workspace\go

Could you update dep and try dep init in that directory?

Updated dep to ec50ada83b429446ce79591220fbfa1db4fd128b

here's what I get:

$ dep init
ctx.DetectProjectGOPATH: both D:\10-workspace\go\src\github.com\F21\dep-gopath-err and D:\10-workspace\go\src\github.com\F21\dep-gopath-err are in the same GOPATH D:\10-workspace\go

$ cd cmd/something_else/

$ dep init
ctx.DetectProjectGOPATH: both D:\10-workspace\go\src\github.com\F21\dep-gopath-err\cmd\something_else and D:\10-workspace\go\src\github.com\F21\dep-gopath-err\cmd\something_else are in the same GOPATH D:\10-workspace\go

I assume this is Git Bash? What about Cmder?

Yes, it's only failing in git bash. Cmder/cmd works fine.

We are reaching somewhere at least. 馃榿

Do you have any idea why Git Bash handles paths differently?

I quick guess is probably that backward slashes do not work in git bash.

For example, if I have D:/some/path, if I am in the D drive and type some\pa, pressing tab to autocomplete does not work.

Does #780 fix this?

Built the latest master, but still seeing the same issue with git bash.

780 only effects dep prune. This one is a bit complicated and I'm not able to determine the root cause yet.

It works fine on Cmder/cmd but it doesn't on Git Bash. The gist output on Git Bash doesn't make much sense. 馃槙

For me it doesn't work in simple cmd.
And what's really weird is that it DOES work for a colleague of mine. With the same repo and the same dep version.

If it helps, this is also happening to me on Windows. I can reproduce in a debugger by placing a lowercase drive letter in the working directory. For example, run dep init in a D:\go\src\myproject and setting the cwd to d:\go\src\myproject The following (in DetectProjectGOPATH() github.com\golangdep\context.go)

    if p.AbsRoot == p.ResolvedAbsRoot {
        return pGOPATH, perr
    }

condition fails because of case difference.

Drive letters should be also treated insensitive on Windows, as some tooling can mangle paths from different sources (for example, having naive scripts using the cygwin mounts /d/... converting to d:/...)

940 should help in solving this one.

I ended up just doing this

// If pGOPATH equals rGOPATH, then both are within the same GOPATH.
    if pGOPATH == rGOPATH {
        if runtime.GOOS == "windows" {
            return pGOPATH, nil
        }

        return "", errors.Errorf("both %s and %s are in the same GOPATH %s", p.AbsRoot, p.ResolvedAbsRoot, pGOPATH)
    }

it's kind of awful ...

Was this page helpful?
0 / 5 - 0 ratings