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: disallowed path element "aux.go" on go get #29589

Closed
tkiraly opened this issue Jan 6, 2019 · 8 comments

Comments

Projects
None yet
6 participants
@tkiraly
Copy link

commented Jan 6, 2019

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

go version go1.11.4 linux/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/tki/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/tki/go"
GOPROXY=""
GORACE=""
GOROOT="/snap/go/3095"
GOTMPDIR=""
GOTOOLDIR="/snap/go/3095/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/tki/src/gitlab.com/tkiraly/auxtest/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build672569542=/tmp/go-build -gno-record-gcc-switches"

What did you do?

go get gitlab.com/tkiraly/auxtest in a directory where there is another project with go.mod

What did you expect to see?

i expected to download the module as a dependency

What did you see instead?

go: finding gitlab.com/tkiraly/auxtest latest
go: downloading gitlab.com/tkiraly/auxtest v0.0.0-20190106140156-e164048c9957
-> unzip /home/tki/go/pkg/mod/cache/download/gitlab.com/tkiraly/auxtest/@v/v0.0.0-20190106140156-e164048c9957.zip: malformed file path "aux.go": disallowed path element "aux.go"
go get: no install location for directory outside GOPATH
For more details see: 'go help gopath'

after renaming the file, the error disappear. aux is a reserved file name??

@mvdan mvdan added the modules label Jan 6, 2019

@mvdan

This comment has been minimized.

Copy link
Member

commented Jan 6, 2019

I can reproduce on tip. Looks like this is on purpose:

// badWindowsNames are the reserved file path elements on Windows.
// See https://docs.microsoft.com/en-us/windows/desktop/fileio/naming-a-file
var badWindowsNames = []string{
        "CON",
        "PRN",
        "AUX",
[...]

I'm not sure if we could make the error better without leaking too much internal detail. /cc @bcmills

@mvdan mvdan added the NeedsDecision label Jan 6, 2019

@mvdan mvdan changed the title disallowed path element "aux.go" cmd/go: disallowed path element "aux.go" on go get Jan 6, 2019

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Jan 6, 2019

Clearly we should improve the error message. It's right there in cmd/go/internal/module/module.go:

	for _, bad := range badWindowsNames {
		if strings.EqualFold(bad, short) {
			return fmt.Errorf("disallowed path element %q", elem)
		}
	}

Any suggestions for what we should say?

@agnivade

This comment has been minimized.

Copy link
Member

commented Jan 7, 2019

Since "malformed file path" is already part of the error message, I think "reserved file path "aux"" might be clearer.

So - malformed file path "aux.go": reserved path element "aux"

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Jan 7, 2019

Thanks. I sort of feel that we should mention Windows somehow.

@mvdan

This comment has been minimized.

Copy link
Member

commented Jan 7, 2019

How about:

malformed file path "aux.go": file name is reserved on some systems

I'd personally say "some systems" instead of "Windows" so we can later add more reserved names on other systems without introducing more error formats.

@tkiraly

This comment has been minimized.

Copy link
Author

commented Jan 7, 2019

The variable name says badwindowsnames so we can say windows not just some systems

However this still misses the key part, that 'aux' word is reserved not aux.go as a whole

How about this?

malformed file path "aux.go": file name part "aux" is reserved on windows

@bcmills

This comment has been minimized.

Copy link
Member

commented Jan 7, 2019

I would prefer that we mention Windows explicitly. Some context will probably help folks feel less confused about why an otherwise-reasonable-looking name is disallowed.

We can wordsmith the exact text in the code review.

@gopherbot

This comment has been minimized.

Copy link

commented Jan 7, 2019

Change https://golang.org/cl/156658 mentions this issue: cmd/go: improve error message for names forbidden by Windows

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.