haskell / haskell/cabal

Corrupt file header when dealing with Unicode normalization issues

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

Description

First, the repro, then the background. This likely only repros on OS X (explained below). Place the following files in a directory:

`Setup.hs`:

```haskell
import Distribution.Simple
main = defaultMain
```

`package.cabal`:

```
name: ば日本-4本
version: 0.1.0.0
build-type: Simple
cabal-version: >=1.10

library
exposed-modules: Lib
build-depends: base >= 4.7 && < 5
default-language: Haskell2010
```

Then run the following series of commands:

```
bash-4.4$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.2.2
bash-4.4$ ghc-pkg list Cabal
/Users/michael/.stack/programs/x86_64-osx/ghc-8.2.2/lib/ghc-8.2.2/package.conf.d
Cabal-2.0.1.0
bash-4.4$ runghc Setup.hs configure --user
Configuring ば日本-4本-0.1.0.0...
bash-4.4$ runghc Setup.hs build
Saved package config file header is corrupt. Re-run the 'configure' command.
```

Expected: Builds the package correctly

Actual: complains repeatedly about corrupt file header. Re-running 'configure' does not help.

## Background

This popped up when debugging a failing integration test in Stack. It turns out that this specific name for a package has a long history on the Stack side, since (on OS X) it appears that some Unicode normalization is applied to filenames, therefore making the sequence of code points stored in the cabal file mismatch the sequence returned by the OS from the generated file name. For a lot more information, see these issues:

* https://github.com/commercialhaskell/stack/issues/3616
* https://github.com/commercialhaskell/stack/pull/3615#issuecomment-348261315
* https://github.com/commercialhaskell/stack/issues/1810

I'm guessing that a similar file name codepoint modification is occurring inside the `dist` directory.

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.