Skip to content

Commit b91e16a

Browse files
committed
Re #6670 Extend S-8432 for non-Latin1 in Stack 'programs' path
1 parent 6af2cd9 commit b91e16a

File tree

2 files changed

+44
-14
lines changed

2 files changed

+44
-14
lines changed

ChangeLog.md

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ Major changes:
1010

1111
Behavior changes:
1212

13+
* Stack will also warn (message S-8432) if there is any non-ISO/IEC 8859-1
14+
(Latin-1) character in Stack's 'programs' path, as `hsc2hs` does not work if
15+
there is such a character in the path to its default template
16+
`template-hsc.h`.
17+
1318
Other enhancements:
1419

1520
Bug fixes:

src/Stack/Config.hs

+39-14
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import Data.Aeson.WarningParser
4141
import Data.Array.IArray ( (!), (//) )
4242
import qualified Data.ByteString as S
4343
import Data.ByteString.Builder ( byteString )
44+
import Data.Char ( isLatin1 )
4445
import Data.Coerce ( coerce )
4546
import qualified Data.Either.Extra as EE
4647
import qualified Data.IntMap as IntMap
@@ -341,33 +342,57 @@ configFromConfigMonoid
341342
Nothing -> getDefaultLocalProgramsBase stackRoot platform origEnv
342343
Just path -> pure path
343344
let localProgramsFilePath = toFilePath localProgramsBase
344-
when (osIsWindows && ' ' `elem` localProgramsFilePath) $ do
345-
ensureDir localProgramsBase
346-
-- getShortPathName returns the long path name when a short name does not
347-
-- exist.
348-
shortLocalProgramsFilePath <-
349-
liftIO $ getShortPathName localProgramsFilePath
345+
spaceInLocalProgramsPath = ' ' `elem` localProgramsFilePath
346+
nonLatin1InLocalProgramsPath = not $ all isLatin1 localProgramsFilePath
347+
problematicLocalProgramsPath =
348+
nonLatin1InLocalProgramsPath
349+
|| (osIsWindows && spaceInLocalProgramsPath)
350+
when problematicLocalProgramsPath $ do
351+
let msgSpace =
352+
[ flow "It contains a space character. This will prevent building \
353+
\with GHC 9.4.1 or later."
354+
| osIsWindows && spaceInLocalProgramsPath
355+
]
356+
msgNoShort <- if osIsWindows && spaceInLocalProgramsPath
357+
then do
358+
ensureDir localProgramsBase
359+
-- getShortPathName returns the long path name when a short name does not
360+
-- exist.
361+
shortLocalProgramsFilePath <-
362+
liftIO $ getShortPathName localProgramsFilePath
363+
pure [ flow "It also has no alternative short ('8 dot 3') name. This \
364+
\will cause problems with packages that use the GNU \
365+
\project's 'configure' shell script."
366+
| ' ' `elem` shortLocalProgramsFilePath
367+
]
368+
else pure []
369+
let msgNonLatin1 = if nonLatin1InLocalProgramsPath
370+
then
371+
[ flow "It contains at least one non-ISO/IEC 8859-1 (Latin-1) \
372+
\character (Unicode code point > 255). This will cause \
373+
\problems with packages that build using the"
374+
, style Shell "hsc2hs"
375+
, flow "tool with its default template"
376+
, style Shell "template-hsc.h" <> "."
377+
]
378+
else []
350379
prettyWarn $
351380
"[S-8432]"
352381
<> line
353382
<> fillSep
354383
( [ flow "Stack's 'programs' path is"
355384
, style File (fromString localProgramsFilePath) <> "."
356-
, flow "It contains a space character. This will prevent \
357-
\building with GHC 9.4.1 or later."
358-
]
359-
<> [ flow "It also has no alternative short ('8 dot 3') name. \
360-
\This will cause problems with packages that use the \
361-
\GNU project's 'configure' shell script."
362-
| ' ' `elem` shortLocalProgramsFilePath
363385
]
386+
<> msgSpace
387+
<> msgNoShort
388+
<> msgNonLatin1
364389
)
365390
<> blankLine
366391
<> fillSep
367392
[ flow "To avoid sucn problems, use the"
368393
, style Shell "local-programs-path"
369394
, flow "non-project specific configuration option to specify an \
370-
\alternative space-free path."
395+
\alternative path without those characteristics."
371396
]
372397
<> line
373398
platformOnlyDir <-

0 commit comments

Comments
 (0)