haskell / haskell/hackage-security
Unrelated withFile error message when renameFile errors
- Dominant language
- Haskell
- Stars
- 63
- Forks
- 56
- PR merge metrics
- No merged PRs in 30d
Description
If I call `downloadPackage'` to a destination directory I haven't created yet, I get a weird error:
```
my-exe: /Users/bchinn/.cache/my-exe/package-index/hackage.haskell.org/01-index.tar: withFile: does not exist (No such file or directory)
```
This is weird because that filepath does exist.
Digging deeper, I found the issue occurs in the `renameFile` call. Because I didn't create the destination directory yet, `renameFile` errors with:
```
renameFile:renamePath:rename '/Users/bchinn/.cache/my-exe/package-index/hackage.haskell.org/Cabal-syntax-3.10.2.0.tar75518-0.gz' to '/Users/bchinn/.cache/my-exe/packages/Cabal-syntax-3.10.2.0': does not exist (No such file or directory)
```
But this error gets swallowed; presumably there's some clean up step that looks for `01-index.tar` and errors before showing the actual error.
A few action items:
1. Document that `downloadPackage` requires directory to exist (or create the directory automatically if it doesn't)
2. Investigate why `withFile` complains about the file not existing when... it does?
3. Check if the destination exists beforehand and show a better error message (contingent on how 1 and 2 get resolved)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.