commercialhaskell / stack

The Haskell Tool Stack
http://haskellstack.org
BSD 3-Clause "New" or "Revised" License
4k stars 843 forks source link

Windows: .../ghc-9.4.8/mingw/bin/strip.exe: error: Permission denied #6627

Open mpilgrem opened 4 months ago

mpilgrem commented 4 months ago

While building happy-1.20.1.1 with GHC 9.4.8 on Windows in CI, @hausfell experienced:

happy > .../ghc-9.4.8/mingw/bin/strip.exe: error: Permission denied

This was during the Setup.hs copy step, which sees Cabal (the library), by default, run strip after having moved the executable file to a new location. For example, during stack --verbose build --cabal-verbose --ghc-options=-v:

2024-07-19 18:17:18.401203: [info] creating
2024-07-19 18:17:18.401203: [info] ...\happy-1.20.1.1\.stack-work\install\fd1b2601\bin
2024-07-19 18:17:18.401203: [info] Installing executable .stack-work\dist\f1a1ac53\build\happy\happy.exe to
2024-07-19 18:17:18.401203: [info] ...\happy-1.20.1.1\.stack-work\install\fd1b2601\bin\happy.exe
2024-07-19 18:17:18.401203: [info] "...\ghc-9.4.8\mingw\bin\strip.exe" "...\happy-1.20.1.1\.stack-work\install\fd1b2601\bin\happy.exe"

I think it must be strip.exe seeking to overwrite happy.exe when it is not yet free to do so, for some reason.

Cabal's Distribution.Simple.GHC.installExe has (extract):

        installBinary dest = do
          installExecutableFile
            verbosity
            (buildPref </> exeName' </> exeFileName)
            (dest <.> exeExtension (hostPlatform lbi))
          when (stripExes lbi) $
            Strip.stripExe
              verbosity
              (hostPlatform lbi)
              (withPrograms lbi)
              (dest <.> exeExtension (hostPlatform lbi))

So, it looks to me that things are properly sequenced. Could it be a problem within the MSYS2-supplied strip.exe itself?

hasufell commented 4 months ago

CI where it first happened: https://github.com/haskell/ghcup-hs/actions/runs/9996272096/job/27630268254?pr=1108

The second run did not suffer from this issue: https://github.com/haskell/ghcup-hs/actions/runs/9996272096/job/27695488770?pr=1108

This suggests it's a spurious failure.