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: go mod vendor: open C:\Users\LICENSE: Access is denied. #46867

Closed
breeze7086 opened this issue Jun 22, 2021 · 21 comments
Closed

cmd/go: go mod vendor: open C:\Users\LICENSE: Access is denied. #46867

breeze7086 opened this issue Jun 22, 2021 · 21 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. OS-Windows
Milestone

Comments

@breeze7086
Copy link

breeze7086 commented Jun 22, 2021

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

$ go version
go version go1.16.5 windows/amd64

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\AMM2SZH\AppData\Local\go-build
set GOENV=C:\Users\AMM2SZH\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\AMM2SZH\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\AMM2SZH\go
set GOPRIVATE=
set GOPROXY=https://goproxy.io,direct
set GOROOT=C:\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.16.5
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\Users\AMM2SZH\go\src\k8s.io\kubernetes\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\AMM2SZH\AppData\Local\Temp\go-build982454655=/tmp/go-build -gno-record-gcc-switches

What did you do?

go mod vendor

What did you expect to see?

go mod works well

What did you see instead?

go mod vendor: open C:\Users\LICENSE: Access is denied.

@davecheney
Copy link
Contributor

Thank you for raising this issue. Unfortunately you haven't provided any information on how someone else can reproduce the problem you are experiencing. Can you please include a way that someone else can reproduce the problem you are seeing.

IMPORTANT: Please do not include screenshots of text, just copy and paste the text directly

@davecheney davecheney added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jun 22, 2021
@breeze7086
Copy link
Author

My login user to my computer has no permission to create any file under the C:\Users directory.
I guess to reproduce this issue, login without the admin user could be the way.

@davecheney
Copy link
Contributor

davecheney commented Jun 22, 2021

It looks like you have a copy of k8s.io/kubernetes checked out in $HOME/go/src/k8s.io/kubernetes. Is that correct?
Which directory are you in? is it $HOME/go/src/k8s.io/kubernetes?

If you can provide a set of commands that gets a windows machine with Go installed to the point of the command that failed; ie, git clone (or however you did it), cd $directory, go mod vendor. That would be of great assistance.

@ghost
Copy link

ghost commented Jun 22, 2021

C:\Users shouldn't be your project's directory.

@mattn
Copy link
Member

mattn commented Jun 22, 2021

pkg = filepath.Dir(pkg)

This should be:

pkg = path.Dir(pkg)

Since pkg is a paths separated with slash (not backslash). I'll send CL.

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/330149 mentions this issue: cmd/go/internal/modcmd: Fixes mod vendor

@breeze7086
Copy link
Author

breeze7086 commented Jun 23, 2021

pkg = filepath.Dir(pkg)

This should be:

pkg = path.Dir(pkg)

Since pkg is a paths separated with slash (not backslash). I'll send CL.

So you mean this is a bug and will be fixed in a future release?

@breeze7086
Copy link
Author

It looks like you have a copy of k8s.io/kubernetes checked out in $HOME/go/src/k8s.io/kubernetes. Is that correct?
Which directory are you in? is it $HOME/go/src/k8s.io/kubernetes?

If you can provide a set of commands that gets a windows machine with Go installed to the point of the command that failed; ie, git clone (or however you did it), cd $directory, go mod vendor. That would be of great assistance.

23/06/2021 10:15.50 /home/mobaxterm cd /drives/c/Users/AMM2SZH/go/src/k8s.io/kubernetes

23/06/2021 10:16.11 /drives/c/Users/AMM2SZH/go/src/k8s.io/kubernetes release-1.16 go mod vendor
go mod vendor: open C:\Users\LICENSE: Access is denied.

@seankhliao
Copy link
Member

which shell / environment (WSL?) are you using?

@breeze7086
Copy link
Author

breeze7086 commented Jul 1, 2021

which shell / environment (WSL?) are you using?

I'm using MobaXterm under the Windows system, I'm sorry to say I have no idea what kind of shell does it use.
Maybe this could help?
image

@bcmills
Copy link
Contributor

bcmills commented Jul 1, 2021

I can reproduce this failure mode locally using the stock cmd.exe shell in a current clone of the https://github.com/kubernetes/kubernetes repo:

C:\tmp\kubernetes>go version
go version devel go1.17-37f9a8f69d Fri Jun 25 01:08:06 2021 +0000 windows/amd64

C:\tmp\kubernetes>go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\bryan\AppData\Local\go-build
set GOENV=C:\Users\bryan\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\bryan\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\bryan\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Users\bryan\src\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Users\bryan\src\go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=devel go1.17-37f9a8f69d Fri Jun 25 01:08:06 2021 +0000
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\tmp\kubernetes\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\bryan\AppData\Local\Temp\go-build1763398445=/tmp/go-build -gno-record-gcc-switches

C:\tmp\kubernetes>go mod vendor
go mod vendor: open C:\LICENSE: Access is denied.

C:\tmp\kubernetes>

@bcmills bcmills added NeedsFix The path to resolution is known, but the work has not been done. OS-Windows and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Jul 1, 2021
@bcmills bcmills added this to the Go1.17 milestone Jul 1, 2021
@bcmills bcmills self-assigned this Jul 1, 2021
@gopherbot
Copy link
Contributor

Change https://golang.org/cl/332250 mentions this issue: cmd/go: add a regression test for 'go mod vendor' path traversal

@dmitshur dmitshur changed the title go mod vendor: open C:\Users\LICENSE: Access is denied. cmd/go: go mod vendor: open C:\Users\LICENSE: Access is denied. Jul 1, 2021
@bcmills
Copy link
Contributor

bcmills commented Jul 1, 2021

@gopherbot, please backport. This bug has a trivial fix, and the failure mode is fairly confusing with no obvious workaround.

@gopherbot
Copy link
Contributor

Backport issue(s) opened: #47014 (for 1.15), #47015 (for 1.16).

Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases.

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/332329 mentions this issue: [release-branch.go1.16] cmd/go: use path.Dir instead of filepath.Dir for package paths in 'go mod vendor'

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/332330 mentions this issue: [release-branch.go1.15] cmd/go: use path.Dir instead of filepath.Dir for package paths in 'go mod vendor'

gopherbot pushed a commit that referenced this issue Jul 1, 2021
For #46867

Change-Id: I1547ebf7b91e9ddd7b67fd2f20e91391d79fa35d
Reviewed-on: https://go-review.googlesource.com/c/go/+/332250
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
gopherbot pushed a commit that referenced this issue Aug 3, 2021
…for package paths in 'go mod vendor'

copyMetadata walk-up to parent directory until the pkg become modPath.
But pkg should be slash-separated paths. It have to use path.Dir instead of
filepath.Dir.

Updates #46867
Fixes #47015

Change-Id: I44cf1429fe52379a7415b94cc30ae3275cc430e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/330149
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Alexander Rakoczy <alex@golang.org>
Trust: Carlos Amedee <carlos@golang.org>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
(cherry picked from commit 835d86a)
Reviewed-on: https://go-review.googlesource.com/c/go/+/332329
Reviewed-by: Jay Conrod <jayconrod@google.com>
gopherbot pushed a commit that referenced this issue Aug 3, 2021
…for package paths in 'go mod vendor'

copyMetadata walk-up to parent directory until the pkg become modPath.
But pkg should be slash-separated paths. It have to use path.Dir instead of
filepath.Dir.

Updates #46867
Fixes #47014

Change-Id: I44cf1429fe52379a7415b94cc30ae3275cc430e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/330149
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Alexander Rakoczy <alex@golang.org>
Trust: Carlos Amedee <carlos@golang.org>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
(cherry picked from commit 835d86a)
Reviewed-on: https://go-review.googlesource.com/c/go/+/332330
Reviewed-by: Jay Conrod <jayconrod@google.com>
Run-TryBot: Carlos Amedee <carlos@golang.org>
@helloxjade
Copy link

$ go mod vendor
go: downloading k8s.io/utils v0.0.0-20210930125809-cb0fa318a74b
go: downloading golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e
go: downloading golang.org/x/net v0.0.0-20210825183410-e898025ed96a
go: downloading sigs.k8s.io/structured-merge-diff/v4 v4.1.2
go: downloading sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.25
go mod vendor: open C:\LICENSE: Access is denied.
I reproduce it in k8s repository

@mattn
Copy link
Member

mattn commented Apr 12, 2022

@helloxjade What version of Go do you use?

@helloxjade
Copy link

helloxjade commented Apr 12, 2022 via email

@bcmills
Copy link
Contributor

bcmills commented Apr 12, 2022

@helloxjade, this issue was fixed in Go 1.17, which is currently the oldest supported Go release (per https://go.dev/doc/devel/release#policy). It was also backported to Go 1.16.7, although that release is no longer supported.

Upgrading to a supported release should solve your issue.

@helloxjade
Copy link

helloxjade commented Apr 13, 2022 via email

@rsc rsc unassigned bcmills Jun 23, 2022
@golang golang locked and limited conversation to collaborators Jun 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. OS-Windows
Projects
None yet
Development

No branches or pull requests

7 participants