Building two components of the same package concurrently causes one to fail
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
Description
**Describe the bug**
When running two cabal processes that build the same project (possibly because they share a third project as a dependency) one will fail. This can occur quite easily when trying to run an entire product stack with tools like `overmind`. I suppose it will not be deterministic but this is the error I saw:
```
: error:
/home/user/company/project/dist-newstyle/build/x86_64-linux/ghc-9.4.4/project/build/Project/Module.o.tmp: renameFile:renamePath:rename: does not exist (No such file or directory)
```
**To Reproduce**
In different terminals run in the same directory:
```
$ cabal build -j all
```
**Expected behavior**
One of the two processes should wait and give a warning about another process building the same project
**System information**
- Operating system: Ubuntu
- `cabal`, `ghc` versions: `cabal-install version 3.10.1.0`, `The Glorious Glasgow Haskell Compilation System, version 9.4.4`
**Possible solution**
Per 'build unit', first claim a lock by writing the PID of the current process to a lockfile. The lock is free if the lock file is missing or the PID inside the lockfile does not refer to an existing process.
Contributor guide
Assessment
This issue has not been assessed yet.