Skip to content

"resource busy (file is locked)" failures running tests locally #11686

@philderbeast

Description

@philderbeast

Describe the bug
I'm seeing "resource busy (file is locked)" failures running tests locally.

To Reproduce

$ cabal test cabal-install:unit-tests
 UnitTests.Distribution.Client.UserConfig
    nullDiffOnCreate:                                                                                                                  FAIL
      Exception: ghc-internal:GHC.Internal.IO.Exception.IOException:
      
      /home/.../cabal/cabal-install/tests/fixtures/project-root/test-user-config.tmp: withFile: resource busy (file is locked)
      
      HasCallStack backtrace:
        ioException, called at libraries/ghc-internal/src/GHC/Internal/IO/FD.hs:331:17 in ghc-internal:GHC.Internal.IO.FD
      
      Use -p '/nullDiffOnCreate/' to rerun this test only.
    canDetectDifference:                                                                                                               OK
    canUpdateConfig:                                                                                                                   FAIL
      Exception: ghc-internal:GHC.Internal.Exception.ErrorCall:
      
      fromFlag NoFlag. Use fromFlagOrDefault
      
      HasCallStack backtrace:
        error, called at src/Distribution/Simple/Flag.hs:83:19 in Cabal-3.17.0.0-inplace:Distribution.Simple.Flag
        fromFlag, called at tests/UnitTests/Distribution/Client/UserConfig.hs:63:5 in cabal-install-3.17.0.0-inplace-unit-tests:UnitTests.Distribution.Client.UserConfig
      
      Use -p '/canUpdateConfig/' to rerun this test only.
    doubleUpdateConfig:                                                                                                                FAIL
      Exception: ghc-internal:GHC.Internal.IO.Exception.IOException:
      
      /home/.../cabal/cabal-install/tests/fixtures/project-root/test-user-config.tmp: withFile: resource busy (file is locked)
      
      HasCallStack backtrace:
        ioException, called at libraries/ghc-internal/src/GHC/Internal/IO/FD.hs:331:17 in ghc-internal:GHC.Internal.IO.FD
      
      Use -p '/doubleUpdateConfig/' to rerun this test only.
    newDefaultConfig:
...

It is not always 3 tests that fail. Here's another run:

 UnitTests.Distribution.Client.UserConfig
    nullDiffOnCreate:                                                                                                                  FAIL
      Exception: ghc-internal:GHC.Internal.IO.Exception.IOException:
      
      /home/.../cabal/cabal-install/tests/fixtures/project-root/test-user-config: withBinaryFile: resource busy (file is locked)
      
      While handling /home/.../cabal/cabal-install/tests/fixtures/project-root/test-user-config: withBinaryFile: resource busy (file is locked)
      
      HasCallStack backtrace:
        ioError, called at src/Distribution/Client/Config.hs:1065:14 in cabal-install-3.17.0.0-inplace:Distribution.Client.Config
      
      Use -p '/nullDiffOnCreate/' to rerun this test only.
    canDetectDifference:                                                                                                               FAIL
      Exception: ghc-internal:GHC.Internal.IO.Exception.IOException:
      
      /home/.../cabal/cabal-install/tests/fixtures/project-root/test-user-config.tmp: withFile: resource busy (file is locked)
      
      HasCallStack backtrace:
        ioException, called at libraries/ghc-internal/src/GHC/Internal/IO/FD.hs:331:17 in ghc-internal:GHC.Internal.IO.FD
      
      Use -p '/canDetectDifference/' to rerun this test only.
    canUpdateConfig:                                                                                                                   FAIL
      Exception: ghc-internal:GHC.Internal.IO.Exception.IOException:
      
      renameFile:renamePath:rename '/home/.../cabal/cabal-install/tests/fixtures/project-root/test-user-config.tmp' to '/home/.../cabal/cabal-install/tests/fixtures/project-root/test-user-config': does not exist (No such file or directory)
      
      While handling renamePath:rename '/home/.../cabal/cabal-install/tests/fixtures/project-root/test-user-config.tmp' to '/home/.../cabal/cabal-install/tests/fixtures/project-root/test-user-config': does not exist (No such file or directory)
      
      Use -p '/canUpdateConfig/' to rerun this test only.

Expected behavior
That these tests pass when run locally.

System information

  • cabal-3.16.1.0
  • ghc-9.14.1
$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 25.10
Release:	25.10
Codename:	questing

I tested with master at cc98704 and as far back as 9a32847 and still see failures.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions