Skip to content

Commit

Permalink
Re #6670 Extend S-8432 for non-Latin1 in Stack 'programs' path
Browse files Browse the repository at this point in the history
  • Loading branch information
mpilgrem committed Dec 15, 2024
1 parent 6af2cd9 commit b91e16a
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 14 deletions.
5 changes: 5 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ Major changes:

Behavior changes:

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

Other enhancements:

Bug fixes:
Expand Down
53 changes: 39 additions & 14 deletions src/Stack/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import Data.Aeson.WarningParser
import Data.Array.IArray ( (!), (//) )
import qualified Data.ByteString as S
import Data.ByteString.Builder ( byteString )
import Data.Char ( isLatin1 )
import Data.Coerce ( coerce )
import qualified Data.Either.Extra as EE
import qualified Data.IntMap as IntMap
Expand Down Expand Up @@ -341,33 +342,57 @@ configFromConfigMonoid
Nothing -> getDefaultLocalProgramsBase stackRoot platform origEnv
Just path -> pure path
let localProgramsFilePath = toFilePath localProgramsBase
when (osIsWindows && ' ' `elem` localProgramsFilePath) $ do
ensureDir localProgramsBase
-- getShortPathName returns the long path name when a short name does not
-- exist.
shortLocalProgramsFilePath <-
liftIO $ getShortPathName localProgramsFilePath
spaceInLocalProgramsPath = ' ' `elem` localProgramsFilePath
nonLatin1InLocalProgramsPath = not $ all isLatin1 localProgramsFilePath
problematicLocalProgramsPath =
nonLatin1InLocalProgramsPath
|| (osIsWindows && spaceInLocalProgramsPath)
when problematicLocalProgramsPath $ do
let msgSpace =
[ flow "It contains a space character. This will prevent building \
\with GHC 9.4.1 or later."
| osIsWindows && spaceInLocalProgramsPath
]
msgNoShort <- if osIsWindows && spaceInLocalProgramsPath
then do
ensureDir localProgramsBase
-- getShortPathName returns the long path name when a short name does not
-- exist.
shortLocalProgramsFilePath <-
liftIO $ getShortPathName localProgramsFilePath
pure [ flow "It also has no alternative short ('8 dot 3') name. This \
\will cause problems with packages that use the GNU \
\project's 'configure' shell script."
| ' ' `elem` shortLocalProgramsFilePath
]
else pure []
let msgNonLatin1 = if nonLatin1InLocalProgramsPath
then
[ flow "It contains at least one non-ISO/IEC 8859-1 (Latin-1) \
\character (Unicode code point > 255). This will cause \
\problems with packages that build using the"
, style Shell "hsc2hs"
, flow "tool with its default template"
, style Shell "template-hsc.h" <> "."
]
else []
prettyWarn $
"[S-8432]"
<> line
<> fillSep
( [ flow "Stack's 'programs' path is"
, style File (fromString localProgramsFilePath) <> "."
, flow "It contains a space character. This will prevent \
\building with GHC 9.4.1 or later."
]
<> [ flow "It also has no alternative short ('8 dot 3') name. \
\This will cause problems with packages that use the \
\GNU project's 'configure' shell script."
| ' ' `elem` shortLocalProgramsFilePath
]
<> msgSpace
<> msgNoShort
<> msgNonLatin1
)
<> blankLine
<> fillSep
[ flow "To avoid sucn problems, use the"
, style Shell "local-programs-path"
, flow "non-project specific configuration option to specify an \
\alternative space-free path."
\alternative path without those characteristics."
]
<> line
platformOnlyDir <-
Expand Down

0 comments on commit b91e16a

Please sign in to comment.