Repository navigation
cmd/go: 'Access is denied' when renaming module cache directory #36568
Description
Activity
- changed the title
[-]Cannot rename dependency mod from name@version.tmp-xxx to name@version[/-][+]Cannot build: when rename dependency mod from name@version.tmp-xxx to name@version, fail[/+]on Jan 15, 2020 - changed the title
[-]Cannot build: when rename dependency mod from name@version.tmp-xxx to name@version, fail[/-][+]cmd/go: Cannot build: when rename dependency mod from name@version.tmp-xxx to name@version, fail[/+]on Jan 15, 2020 - addedWaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.Issue is not actionable because of missing required information, which needs to be provided.
on Jan 16, 2020 - changed the title
[-]cmd/go: Cannot build: when rename dependency mod from name@version.tmp-xxx to name@version, fail[/-][+]cmd/go: cannot build when rename dependency mod from name@version.tmp-xxx to name@version[/+]on Jan 16, 2020 @kiwionly Could you provide an example of the code that produced the error, preferably as a Go playground link?
Seems like the same issue as microsoft/vscode-go#2897. We've never been able to reproduce this.
Could you post a listing of the directory
C:\Users\502380\go\pkg\mod\golang.org\x\?
Are you able to reproduce this or did it just happen once? How about after clearing the module cache withgo clean -modcache?Reacted by Luis Gabriel Gomez, Samuel Hawksby-Robinson and Felix ツ- changed the title
[-]cmd/go: cannot build when rename dependency mod from name@version.tmp-xxx to name@version[/-][+]cmd/go: '[/+]on Jan 16, 2020 - changed the title
[-]cmd/go: '[/-][+]cmd/go: 'Access is denied' when renaming module cache directory[/+]on Jan 16, 2020 @cagedmantis @jayconrod I am doing go build with module using Jetbrain Goland, some how command prompt also able to produce the error.
Note that my application contain a lot of dependency, and i need to rerun > go build , sometime it success, sometime it will fail with error message below ( depend on the package, some package will have issue, then I run go build again, no more issue/)
Here is the error when running in command prompt using go get, but actually the error is same ( except go build is loading a lot of dependency compare to go get below, but github.com/go-playground/locales is the one that always fail )
C:\Users\502380\GolandProjects\myproject>go get github.com/go-playground/universal-translator go: finding github.com/go-playground/universal-translator v0.17.0 go: downloading github.com/go-playground/universal-translator v0.17.0 go: extracting github.com/go-playground/universal-translator v0.17.0 go: downloading github.com/go-playground/locales v0.13.0 go: extracting github.com/go-playground/locales v0.13.0 ..\..\go\pkg\mod\github.com\go-playground\universal-translator@v0.17.0\errors.go:7:2: rename C:\Users\502380\go\pkg\mod\github.com\go-playground\locales@v0.13.0.tmp-022886503 C:\Users\502380\go\pkg\mod\github.com\go-playground\locales@v0.13.0: Access is denied.For the
renameof that directory, we use a separate lockfile:
go/src/cmd/go/internal/modfetch/fetch.go
Line 76 in 6718cb6
unlock, err := lockVersion(mod) go/src/cmd/go/internal/modfetch/fetch.go
Lines 82 to 83 in 6718cb6
// Check whether the directory was populated while we were waiting on the lock. fi, err = os.Stat(dir) go/src/cmd/go/internal/modfetch/fetch.go
Line 122 in 6718cb6
if err := os.Rename(tmpDir, dir); err != nil { So the only possibilities I can see for this failure are:
- A bug in our
lockedfile.Mutexoros.Renameimplementation is causing the file-locks to not actually synchronize the other I/O operations. - Something (perhaps Goland, or perhaps an antivirus scanner?) is accessing one or both of the directories to be renamed without holding the associated file lock.
- A bug in the Windows kernel or filesystem implementation is causing the file-locks to not actually synchronize the other I/O operations.
Of course, it is also possible that I have missed something.
For cause (1), we should fix our implementation.
For cause (2) or (3), we should ensure that a bug is filed against the appropriate other project, and then we could perhaps use
robustio.Renameinstead ofos.Renameif we believe that will help. However, I would want some way to empirically reproduce and measure the problem and the mitigation to verify that it actually does help.CC @jstarks @alexbrainman @zx2c4 @networkimprov in case they have any insights into how to debug this.
- A bug in our
- addedNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.DevExpanything around developer experienceanything around developer experienceand removedWaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.Issue is not actionable because of missing required information, which needs to be provided.
on Jan 22, 2020 86 remaining items
@kiwionly do u use Ubuntu 18.04 on windows 10 ?
do u use Mcafee Endpoint Security ?
if so just search and find ubuntu1804.exe in your system
then right click ubuntu1804.exe-> properties -> compatibility(second tab) -> Setting(select run as administration ) ,then click Application (A) , all is ok ;if it still build fail ,please click security tab , and click Advaced(V)
make sure your account access has Complete control ,default all allow is TrustedInstaller user ,this will prevented by Mcafee ;wish it helped all who met this err ,I had troubled by it for months ;
@kiwionly do u use Ubuntu 18.04 on windows 10 ?
do u use Mcafee Endpoint Security ?
if so just search and find ubuntu1804.exe in your system
then right click ubuntu1804.exe-> properties -> compatibility(second tab) -> Setting(select run as administration ) ,then click Application (A) , all is ok ;if it still build fail ,please click security tab , and click Advaced(V)
make sure your account access has Complete control ,default all allow is TrustedInstaller user ,this will prevented by Mcafee ;wish it helped all who met this err ,I had troubled by it for months ;
@herohenu I build GO on window 10 with McAfee, unfortunately I no admin right to change any settings.
Anyway, thx for your remind.
Also hit this issue:
- Windows 10 1903/18362.1016 with debian under WSL 1.
go version go1.15 linux/amd64- Running McAfee AV. There's both the on-demand scanning and currently a schedule scan running
- I had gone so far as to
rm -rf ~/go/*but that didn't help - Worked around with:
GODEBUG=modcacheunzipinplace=1 go mod tidy
For fellow McAfee sufferers, this vague page may be related: https://kc.mcafee.com/corporate/index?page=content&id=KB91411
Reacted by Hristo Boyanov, perspectivus1 and Carlos D'AgostinoChange https://golang.org/cl/258798 mentions this issue:
cmd/go/internal/modfetch: always extract module directories in placeIs the fix from https://golang.org/cl/258798 part of release go1.16beta1 ?
@egodigitus, yes, that change is included in
go1.16beta1.Reacted by egodigitusgo1.16beta1fixed the bug for me 👍
OS: Windows 10
Running golang inside WSL Ubuntu 20.04- locked and limited conversation to collaborators
on Jan 27, 2022 - added a commit that references this issue
on Apr 29, 2024
What version of Go are you using (
go version)?13.6
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env)?Window 10, intel
go envOutputWhat did you do?
I had a mod file which is 1.13
When I run go build, it download the dependency, however, it end with error like this. e.g.
cannot load golang.org/x/net/html: rename C:\Users\502380\go\pkg\mod\golang.org\x\net@v0.0.0-20190620200207-3b0461eec859.tmp-839788141 C:\Users\502380\go\pkg\mod\golang.org\x\net@v0.0.0-20190620200207-3b0461eec859:
What did you expect to see?
build should successful without any error.
What did you see instead?
#This is running in jetbrain goland
go: extracting golang.org/x/net v0.0.0-20190620200207-3b0461eec859
build command-line-arguments: cannot load golang.org/x/net/html: rename C:\Users\502380\go\pkg\mod\golang.org\x\net@v0.0.0-20190620200207-3b0461eec859.tmp-839788141 C:\Users\502380\go\pkg\mod\golang.org\x\net@v0.0.0-20190620200207-3b0461eec859: Access is denied.