haskell / haskell/cabal

Throw better error when cannot remove log file

Open
#11,590 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

There are a few places where Cabal creates a log file for a package build roughly along these lines (grep for `removeFile.*log`)
```haskell
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".

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.