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

"you don't have permission to modify this file" error on Windows #3492

Closed
varosi opened this issue Oct 16, 2017 · 10 comments
Closed

"you don't have permission to modify this file" error on Windows #3492

varosi opened this issue Oct 16, 2017 · 10 comments

Comments

@varosi
Copy link

varosi commented Oct 16, 2017

Steps to reproduce

On Windows 10 x64 run:

  1. stack install ghc-mod

Expected

Not to have this problem. Eventually to retry internally if it cannot modify this file. I suspect that this is some kind of multi-threading problem with write accessing this file.

Actual

At some time you'll get on Windows (not every time, but often):

C:\sr\snapshots\fe0c6596\pkgdb\package.cache: you don't have permission to modify this file

If you retry the build - it continues and there is no problem. But on some larger projects two or three continues are needed. This is unacceptable on CI/CD systems or automatic retry mechanism should be implemented.

Stack version

$ stack --version
Version 1.5.1, Git revision 600c1f01435a10d127938709556c1682ecfd694e x86_64 hpack-0.17.1

Method of installation

  • Official binary
@paulrzcz
Copy link
Collaborator

I also saw this error on windows boxes but my suspicion is that it happens due to antivirus. At least, currently used antivirus sometimes causes similar problems on msbuilds too.

I cannot switch off antivirus due to corporate policies. Could you, please, try to exclude antivirus stuff?

@mgsloan
Copy link
Contributor

mgsloan commented Oct 17, 2017

Can you please paste a stack build -v --cabal-verbose log of when this happens? I think this is being thrown by a ghc-pkg call, which in this case is invoked by Cabal. So what's happening here is quite out of the control of stack, and should either be fixed in Cabal or ghc.

@tfausak
Copy link
Contributor

tfausak commented Oct 18, 2017

I also run into this problem every now and then. It's hard to reproduce because, as mentioned, re-running the command usually succeeds. The only anti-virus I have installed is Windows Defender.

@varosi
Copy link
Author

varosi commented Oct 18, 2017

I think that Stack could have some kind of retry on some operations in case of such failure.

@rubin55
Copy link

rubin55 commented Oct 19, 2017

I also am running into this issue: I usually do a stack exec -- ghc-pkg unregister --force <some-package> and then run stack build again to fix the issue. It usually happens about 10 times out of a 100.

@keremispirli
Copy link

We also experience this in our Windows CI (AppVeyor).
Here are logs from our latest build that failed due to this problem:

Installing library in
    C:\TorXakis\.stack\snapshots\ddadf15f\lib\x86_64-windows-ghc-8.0.2\hspec-core-2.4.4-HfxBR0YrMu77yIMWFmbbw5
    Registering hspec-core-2.4.4...
    Cabal-simple_Z6RU0evB_1.24.2.0_ghc-8.0.2.exe:
    'C:\Users\appveyor\AppData\Local\Programs\stack\x86_64-windows\ghc-integersimple-8.0.2\bin\ghc-pkg.EXE'
    exited with an error:
    hspec-core-2.4.4: Warning: haddock-interfaces:
    C:\TorXakis\.stack\snapshots\ddadf15f\doc\hspec-core-2.4.4\hspec-core.haddock
    doesn't exist or isn't a file
    ghc-pkg.EXE: C:\TorXakis\.stack\snapshots\ddadf15f\pkgdb\package.cache: you
    don't have permission to modify this file

I have 2 more builds that failed due to this error just last week, all while building different packages. So the problem does look like how @varosi suspected:

I suspect that this is some kind of multi-threading problem with write accessing this file.

I will add -v --cabal-verbose to my feature branch builds to have the logs @mgsloan requested when it happens again.

@cleverca22
Copy link

this appears to be a duplicate of #2617

@mgsloan
Copy link
Contributor

mgsloan commented Dec 1, 2017

@cleverca22 Ah good point. So, to others in this thread, and readers from searches:

The likely workaround is to switch to GHC 8.2.1

@varosi
Copy link
Author

varosi commented Dec 14, 2017

This problem seems to be fixed on GHC 8.2.1, but there is another one which occurs the same way - randomly and prevent the build from finishing successfully. But it seems like it's another problem.

joelburget added a commit to joelburget/pact that referenced this issue Feb 22, 2018
Our latest appveyor build failed with:

```
ghc-pkg.EXE: C:\sr\snapshots\141c7015\pkgdb\package.cache: you don't have
permission to modify this file
```

According to commercialhaskell/stack#3492,
"The likely workaround is to switch to GHC 8.2.1", so this moves to
lts-10.6 (ghc 8.2.2).
joelburget added a commit to joelburget/pact that referenced this issue Feb 22, 2018
Our latest appveyor build failed with:

```
ghc-pkg.EXE: C:\sr\snapshots\141c7015\pkgdb\package.cache: you don't have
permission to modify this file
```

According to commercialhaskell/stack#3492,
"The likely workaround is to switch to GHC 8.2.1", so this moves to
lts-10.6 (ghc 8.2.2).
@varosi
Copy link
Author

varosi commented Mar 20, 2018

On latest GHCs I don't get this message.

@varosi varosi closed this as completed Mar 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants