Skip to content

Syscall: TestScript/mod_cache_rw failed on window-amd64 #35813

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

Closed
erifan opened this issue Nov 25, 2019 · 9 comments
Closed

Syscall: TestScript/mod_cache_rw failed on window-amd64 #35813

erifan opened this issue Nov 25, 2019 · 9 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Windows Testing An issue that has been verified to require only test changes, not just a test failure. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@erifan
Copy link

erifan commented Nov 25, 2019

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

$ go version
go version devel +9940c77 Mon Nov 25 03:41:16 2019 +0000 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=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\hostname\AppData\Local\go-build
set GOENV=C:\Users\hostname\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\hostname\OneDrive - ARM\Desktop\goPath
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Users\hostname\OneDrive - ARM\Desktop\golang
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Users\hostname\OneDrive - ARM\Desktop\golang\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\Users\hostname\OneDrive - ARM\Desktop\go-test-master\src\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\hostname\AppData\Local\Temp\go-build077161794=/tmp/go-build -gno-record-gcc-switches

What did you do?

$ cd go\src
$ ./all.bat

What did you expect to see?

All tests pass

What did you see instead?

--- FAIL: TestScript (0.00s)
--- FAIL: TestScript/mod_cache_rw (1.81s)
script_test.go:193:
# Regression test for golang.org/issue/31481. (0.000s)
# golang.org/issue/31481: an explicit flag should make directories in the module
# cache writable in order to work around the historical inability of 'rm -rf' to
# forcibly remove files in unwritable directories. (1.051s)
# After adding an extraneous file, 'go mod verify' should fail. (0.207s)
# However, files within those directories should still be read-only to avoid
# accidental mutations. (0.001s)
# If all 'go' commands ran with the flag, the system's 'rm' binary
# should be able to remove the module cache if the '-rf' flags are set. (0.115s)
> [!windows] [exec:rm] exec rm -rf $GOPATH/pkg/mod
> [!windows] [!exec:rm] go clean -modcache
> [windows] [exec:rmdir] exec rmdir /s /q $GOPATH\pkg\mod
[stderr]
rmdir: failed to remove '/s': No such file or directory
rmdir: failed to remove '/q': No such file or directory
rmdir: failed to remove '$WORK\gopath\pkg\mod': Directory not empty
[exit status 1]
FAIL: testdata\script\mod_cache_rw.txt:22: unexpected command failure

FAIL
FAIL cmd/go 299.986s

This failure has been pointed out in #35033, but the issue ticket has been closed, so I reopened this one. I don't know if I need to add some extra settings to build and test Go on Windows.

@bcmills
Copy link
Contributor

bcmills commented Nov 25, 2019

What version of Windows was this on? It looks like for some reason it didn't parse the /s and /q switches as switches.

Looking at https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/rd, perhaps some (all?) versions of Windows require the path to precede the switches?

@bcmills
Copy link
Contributor

bcmills commented Nov 25, 2019

Hmm, but the examples in https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/rd#BKMK_examples pass the switches first too.

@bcmills
Copy link
Contributor

bcmills commented Nov 25, 2019

@alexbrainman, @zx2c4: any idea what's going on here? I'm sure I'm missing something pretty fundamental, but I don't know what.

@bcmills bcmills added OS-Windows NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Testing An issue that has been verified to require only test changes, not just a test failure. labels Nov 25, 2019
@bcmills bcmills added this to the Go1.14 milestone Nov 25, 2019
@bcmills bcmills self-assigned this Nov 25, 2019
@bcmills
Copy link
Contributor

bcmills commented Nov 25, 2019

@erifan, it would be really helpful to know what version of Windows this is on.

@bcmills bcmills added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Nov 25, 2019
@zx2c4
Copy link
Contributor

zx2c4 commented Nov 25, 2019

rmdir or rd is a command built-in to cmd.exe. You can evoke cmd.exe /c and run it from there (sort of like sh -c). Maybe powershell is configured as the default shell on the OP's computer, and so it's using the powershell rmdir alias to Remove-Item instead of cmd.exe's built-in.

@zx2c4
Copy link
Contributor

zx2c4 commented Nov 25, 2019

Seems like it might be easier to have a built-in rmdir_r and rmdir or similar as part of the script executor, so we don't need all of this [windows:...,[!windows:... stuff?

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/208639 mentions this issue: cmd/go: prefix calls to Windows rmdir with cmd.exe

@bcmills
Copy link
Contributor

bcmills commented Nov 25, 2019

Seems like it might be easier to have a built-in

This test is specifically for OS-provided rm-like commands, since (for example) the removeAll function defined in go_test.go can remove directory trees on Linux that rm -rf (as a non-root user) cannot.

@erifan
Copy link
Author

erifan commented Nov 26, 2019

@erifan, it would be really helpful to know what version of Windows this is on.

The Windows version information is as follow:
Edition: Windows 10 Enterprise
Version: 1809
OS build: 17763.864
I tested the latest code, this problem has disappeared. Thanks @bcmills @zx2c4

@golang golang locked and limited conversation to collaborators Nov 25, 2020
@rsc rsc unassigned bcmills Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Windows Testing An issue that has been verified to require only test changes, not just a test failure. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants