fdopen / opam-repository-mingw

windows package repository for OPAM (mingw and msvc)
https://fdopen.github.io/opam-repository-mingw/
Creative Commons Zero v1.0 Universal
96 stars 34 forks source link

Can't install dune-configurator (cp: cannot create regular file ... permission denied) #71

Closed mroch closed 3 years ago

mroch commented 4 years ago

I've been having trouble installing dune-configurator. Here are the logs: https://gist.github.com/mroch/b42338e16fdb53c24a9cc164866e0a51

What I gather is that both dune and dune-configurator contain the same dune-2.1.2.tbz, which hashes to 9c3278ebb3ec14dc4b1880671371985edcd6cbb979260dd403f28acabbcc5faf. so it copies the .tbz to the same path in the cache twice:

+ C:\tools\cygwin\bin\cp.exe "C:/Users/circleci/project/_opam/.opam-switch/sources/dune.2.1.2/dune-2.1.2.tbz" "C:/Users/circleci/.opam/download-cache/sha256/9c/9c3278ebb3ec14dc4b1880671371985edcd6cbb979260dd403f28acabbcc5faf"
[...]
+ C:\tools\cygwin\bin\cp.exe "C:/Users/circleci/project/_opam/.opam-switch/sources/dune-configurator.2.1.2/dune-2.1.2.tbz" "C:/Users/circleci/.opam/download-cache/sha256/9c/9c3278ebb3ec14dc4b1880671371985edcd6cbb979260dd403f28acabbcc5faf"
- /usr/bin/cp: cannot create regular file 'C:/Users/circleci/.opam/download-cache/sha256/9c/9c3278ebb3ec14dc4b1880671371985edcd6cbb979260dd403f28acabbcc5faf': Permission denied

the second time, it fails presumably because it already exists, and there must be something weird about the permissions on Windows because that works fine elsewhere.

fdopen commented 4 years ago

That's an unfortune error. cygwin based tools like cp won't report any helpful error messages, if there is something wrong with the underlying windows permissions.

Does it always fail at this point or just randomly? Does it also happen, when you set OPAMDOWNLOADJOBS to 1?

(See also https://github.com/ocaml/opam/issues/3741 . This should never been triggered at this point in the first place....)

mroch commented 4 years ago

it fails quite often but it doesn't always fail, so it seems like a race. assuming that's what you're getting at with OPAMDOWNLOADJOBS=1. i'll try that out now.

I don't have a lot of Windows experience but did some googling... it seems nontrivial to figure out what the permission issue could be. willing to try whatever, if you know what to do, though!

mroch commented 4 years ago

OPAMDOWNLOADJOBS=1 seems like it works. I've only tested it once so far, but it downloads dune first, then [dune-configurator.2.1.2] found in cache. thanks!

fdopen commented 4 years ago

Ok, I was able to reproduce it and hopefully fixed it. You can try it out now: https://github.com/fdopen/opam-repository-mingw/releases/download/0.0.0.2t/opam64.tar.xz (It will be available at the usual URL when I've tested it more carefully)

The error shouldn't be triggered any longer, even without 'OPAMDOWNLOADJOBS=1'.

fdopen commented 3 years ago

The change is included in the officially linked version for some months now and nobody has reported a similar issue again. I will therefore close this issue.

dra27 commented 3 years ago

@fdopen - would it be possible to see the patches to opam for this, please?

fdopen commented 3 years ago

Sorry, I didn't really fix the problem ( probably https://github.com/ocaml/opam/issues/3741 or related ). I've just added a dirty ad-hoch check, if the file already exist at this location: https://github.com/ocaml/opam/blob/f9b63f4c8176baa387e70cd403f5e53127a742d4/src/repository/opamRepository.ml#L156