commercialhaskell / commercialhaskell/stack

Odd behaviour on unregister with `stack run` for a multi-executable project

Open
#5,975 0 comments 0 reactions 0 assignees View on GitHub
component: Windows
Dominant language
Haskell
Stars
4.1k
Forks
850
Avg merge
10h 37m
Merged PRs (30d)
4

Description

My test is a simple - 'A' and 'B' - multi-executable project (see https://github.com/commercialhaskell/stack/issues/5974#issuecomment-1356331052 for its description). When using `stack run` and switching between executables as the target, I get (with `--verbose`) (extract, output reformatted for ease of reference):
~~~text
2022-12-18 11:56:48.983774: [info] multiExe-0.1.0.0: unregistering (components added: exe:multiExeB)

2022-12-18 11:56:48.984772: [debug] Run process: C:\Users\mike\AppData\Local\Programs\stack\x86_64-windows\ghc-9.2.5\bin\ghc-pkg-9.2.5.exe
--no-user-package-db
--package-db=D:\Users\mike\Code\Haskell\multiExe\.stack-work\install\275f83a7\pkgdb\
unregister
--user
--force
--ipid multiExe-0.1.0.0-4bO8x8ZwRvUFOzjMHcfUPb

2022-12-18 11:56:48.999604: [debug] Run process: C:\Users\mike\AppData\Local\Programs\stack\x86_64-windows\ghc-9.2.5\bin\ghc-pkg-9.2.5.exe
--no-user-package-db
--package-db=D:\Users\mike\Code\Haskell\multiExe\.stack-work\install\275f83a7\pkgdb\
unregister
--user
--force
--ipid multiExe-0.1.0.0-4bO8x8ZwRvUFOzjMHcfUPb

2022-12-18 11:56:49.013602: [warn] Received ExitFailure 1 when running
Raw command: "C:\\Users\\mike\\AppData\\Local\\Programs\\stack\\x86_64-windows\\ghc-9.2.5\\bin\\ghc-pkg-9.2.5.exe" --no-user-package-db "--package-db=D:\\Users\\mike\\Code\\Haskell\\multiExe\\.stack-work\\install\\275f83a7\\pkgdb\\" unregister --user --force --ipid multiExe-0.1.0.0-4bO8x8ZwRvUFOzjMHcfUPb
Standard error:

ghc-pkg-9.2.5.exe: D:\Users\mike\Code\Haskell\multiExe\.stack-work\install\275f83a7\pkgdb\package.cache.lock: openBinaryFile: resource busy (file is locked)
~~~

Compare and contrast with the equivalent `stack --verbose build multiExe:exe:multiExeB` output, which is as expected (output reformatted for ease of reference):

~~~text
2022-12-18 11:59:09.448979: [info] multiExe-0.1.0.0: unregistering (components added: exe:multiExeB)
2022-12-18 11:59:09.448979: [debug] Run process: C:\Users\mike\AppData\Local\Programs\stack\x86_64-windows\ghc-9.2.5\bin\ghc-pkg-9.2.5.exe
--no-user-package-db
--package-db=D:\Users\mike\Code\Haskell\multiExe\.stack-work\install\275f83a7\pkgdb\
unregister
--user
--force
--ipid multiExe-0.1.0.0-4bO8x8ZwRvUFOzjMHcfUPb
2022-12-18 11:59:09.470078: [debug] Process finished in 21ms: C:\Users\mike\AppData\Local\Programs\stack\x86_64-windows\ghc-9.2.5\bin\ghc-pkg-9.2.5.exe --no-user-package-db --package-db=D:\Users\mike\Code\Haskell\multiExe\.stack-work\install\275f83a7\pkgdb\ unregister --user --force --ipid multiExe-0.1.0.0-4bO8x8ZwRvUFOzjMHcfUPb
~~~

In the `stack run` version, the same `unregister` command appears to be issued twice and one of them fails because `package.cache.lock` is 'locked'. That failure is non-fatal.

This appears to be Windows-specific, because it does not appear in the (Linux) report at #5974.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.