@@ -41,6 +41,7 @@ import Data.Aeson.WarningParser
41
41
import Data.Array.IArray ( (!) , (//) )
42
42
import qualified Data.ByteString as S
43
43
import Data.ByteString.Builder ( byteString )
44
+ import Data.Char ( isLatin1 )
44
45
import Data.Coerce ( coerce )
45
46
import qualified Data.Either.Extra as EE
46
47
import qualified Data.IntMap as IntMap
@@ -341,33 +342,57 @@ configFromConfigMonoid
341
342
Nothing -> getDefaultLocalProgramsBase stackRoot platform origEnv
342
343
Just path -> pure path
343
344
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 []
350
379
prettyWarn $
351
380
" [S-8432]"
352
381
<> line
353
382
<> fillSep
354
383
( [ flow " Stack's 'programs' path is"
355
384
, 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
363
385
]
386
+ <> msgSpace
387
+ <> msgNoShort
388
+ <> msgNonLatin1
364
389
)
365
390
<> blankLine
366
391
<> fillSep
367
392
[ flow " To avoid sucn problems, use the"
368
393
, style Shell " local-programs-path"
369
394
, flow " non-project specific configuration option to specify an \
370
- \alternative space-free path."
395
+ \alternative path without those characteristics ."
371
396
]
372
397
<> line
373
398
platformOnlyDir <-
0 commit comments