Skip to content

Throw better error when cannot remove log file #11590

@Bodigrim

Description

@Bodigrim

There are a few places where Cabal creates a log file for a package build roughly along these lines (grep for removeFile.*log)

      initLogFile :: IO ()
      initLogFile =
        case mlogFile of
          Nothing -> return ()
          Just logFile -> do
            createDirectoryIfMissing True (takeDirectory logFile)
            exists <- doesFileExist logFile
            when exists $ removeFile logFile

The problem is that if such log file exists, it's likely that it's another instance of Cabal building the same package and of course locking the log file. So removeFile logFile fails with a cryptic access denied error. We should catch the error and write a reasonable error message. Something like "Log file for package foo is locked, probably by another instance of Cabal".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions