Ticket #626 (reopened defect)

Opened 3 years ago

Last modified 20 months ago

Package build error due to unicode

Reported by: basvandijk Owned by:
Priority: normal Milestone:
Component: Cabal library Version: 1.6.0.1
Severity: normal Keywords:
Cc: Difficulty: unknown
GHC Version: Platform:

Description

The following packages don't build on hackage due to the same error:

*  http://hackage.haskell.org/package/regions-0.3

*  http://hackage.haskell.org/package/ftdi-0.1

The  log contains the following error:

haddock: internal Haddock or GHC error: dist/doc/html/regions/regions.txt: commitAndReleaseBuffer: invalid argument (Invalid or incomplete multibyte or wide character)

I think the .txt file is generated because of the haddock --hoogle flag.

Note that these package make heavy use of Unicode syntax and symbols.

Note that cabal haddock works perferctly on my local system (tested with ghc-6.10.4 + haddock-2.5 + cabal-install-0.6.2 and ghc-6.12.1 + haddock-2.6.0 + cabal-install-0.8.0)

Change History

Changed 3 years ago by ross

  • status changed from new to closed
  • resolution set to fixed

needed to build docs in a UTF8 locale.

Changed 20 months ago by nomeata

  • status changed from closed to reopened
  • resolution fixed deleted

I think this is a bug; the behaviour of "Setup haddock" should not depend on the locale of the user; this did bite the Debian package maintainers:  http://bugs.debian.org/645573

I guess this can be fixed by a simple call to hSetEncoding.

Changed 20 months ago by ross

  • component changed from hackageDB website to Cabal library

OK, that would need to be done in the library.

Changed 20 months ago by nomeata

I am currently testing this patch, and will report if it works:

--- ghc-7.0.4.orig/libraries/Cabal/Distribution/Simple/Haddock.hs
+++ ghc-7.0.4/libraries/Cabal/Distribution/Simple/Haddock.hs
@@ -109,7 +109,7 @@ import Data.Maybe    ( fromMaybe, listTo
 
 import System.FilePath((</>), (<.>), splitFileName, splitExtension,
                        normalise, splitPath, joinPath)
-import System.IO (hClose, hPutStrLn)
+import System.IO (hClose, hPutStrLn, hSetEncoding, utf8)
 import Distribution.Version
 
 -- Types 
@@ -380,6 +380,7 @@ renderArgs verbosity version args k = do
   createDirectoryIfMissingVerbose verbosity True outputDir
   withTempFile outputDir "haddock-prolog.txt" $ \prologFileName h -> do
           do
+             hSetEncoding h utf8
              hPutStrLn h $ fromFlag $ argPrologue args
              hClose h 
              let pflag = (:[]).("--prologue="++) $ prologFileName

Changed 20 months ago by nomeata

Hmm, this write the prologue, but then haddock fails with the same error.

 http://www.haskell.org/haddock/doc/html/ch03s08.html Says that Unicode characters should be escaped. So I guess this should happen here as well. Or just haddock be made unicode aware...

Note: See TracTickets for help on using tickets.