Skip to content

Race condition in cabal build #12079

Description

@isomorpheme

Describe the bug
Running multiple cabal builds at the same time will crash at least one of them with an error ghc-pkg-{...}: cannot create: {...}/dist-newstyle/packagedb/ghc-{...} already exists.

To Reproduce

$ cabal init  # Use default options.
$ cabal clean
$ cabal build & cabal build

One of the two cabal builds should fail.

Expected behavior

cabal build succeeds regardless of if there are any other cabal builds running for the project.

System information

  • Operating system: Ubuntu 24.04.4 LTS
$ cabal --version
cabal-install version 3.16.1.0 
compiled using version 3.16.1.0 of the Cabal library (in-tree)
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 9.10.3

Additional context

#11329 and #11298 seem related, but there the error is about something under the global .cabal dir, not dist-newstyle.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions