@@ -158,7 +158,8 @@ import Stack.Types.Platform
158
158
, platformOnlyRelDir )
159
159
import Stack.Types.Runner ( HasRunner (.. ) )
160
160
import Stack.Types.SetupInfo ( SetupInfo (.. ) )
161
- import Stack.Types.SourceMap ( SMActual (.. ), SourceMap (.. ) )
161
+ import Stack.Types.SourceMap
162
+ ( SMActual (.. ), SMWanted (.. ), SourceMap (.. ) )
162
163
import Stack.Types.Version
163
164
( VersionCheck , stackMinorVersion , stackVersion )
164
165
import Stack.Types.VersionedDownloadInfo
@@ -198,7 +199,7 @@ data SetupPrettyException
198
199
| InvalidGhcAt ! (Path Abs File ) ! SomeException
199
200
| ExecutableNotFound ! [Path Abs File ]
200
201
| SandboxedCompilerNotFound ! [String ] ! [Path Abs Dir ]
201
- | UnsupportedSetupCombo ! OS ! Arch
202
+ | UnsupportedSetupCombo ! OS ! Arch ! StyleDoc ! StyleDoc
202
203
| MissingDependencies ! [String ]
203
204
| UnknownCompilerVersion
204
205
! (Set. Set Text )
@@ -310,17 +311,20 @@ instance Pretty SetupPrettyException where
310
311
\tools, see the output of"
311
312
, style Shell (flow " stack uninstall" ) <> " ."
312
313
]
313
- pretty (UnsupportedSetupCombo os arch) =
314
+ pretty (UnsupportedSetupCombo os arch tool suggestion ) =
314
315
" [S-1852]"
315
316
<> line
316
317
<> fillSep
317
- [ flow " Stack does not know how to install GHC for the combination of \
318
- \operating system"
318
+ [ flow " Stack does not know how to install"
319
+ , tool
320
+ , flow " for the combination of operating system"
319
321
, style Shell (pretty os)
320
322
, " and architecture"
321
323
, style Shell (pretty arch) <> " ."
322
324
, flow " Please install manually."
323
325
]
326
+ <> blankLine
327
+ <> suggestion
324
328
pretty (MissingDependencies tools) =
325
329
" [S-2126]"
326
330
<> line
@@ -1081,7 +1085,21 @@ ensureMsys sopts getSetupInfo' = do
1081
1085
Nothing
1082
1086
| soptsInstallIfMissing sopts -> do
1083
1087
si <- runMemoized getSetupInfo'
1084
- osKey <- getOSKey platform
1088
+ let suggestion = fillSep
1089
+ [ flow " To install manually MSYS2, its root directory \
1090
+ \should be named"
1091
+ , style Dir " msys2-yyyymmdd"
1092
+ , flow " (where yyyymmdd is the date-based version) and the \
1093
+ \directory should be accompanied by a file with the \
1094
+ \same name and extension"
1095
+ , style File " .installed"
1096
+ , flow " (which marks the MSYS2 version as installed). \
1097
+ \Those two items should be located in the \
1098
+ \subdirectory for the specified platform in Stack's \
1099
+ \directory for local tools"
1100
+ , parens (pretty localPrograms) <> " ."
1101
+ ]
1102
+ osKey <- getOSKey " MSYS2" suggestion platform
1085
1103
config <- view configL
1086
1104
VersionedDownloadInfo version info <-
1087
1105
case Map. lookup osKey $ siMsys2 si of
@@ -1094,7 +1112,7 @@ ensureMsys sopts getSetupInfo' = do
1094
1112
tool
1095
1113
(installMsys2Windows si)
1096
1114
| otherwise -> do
1097
- prettyWarnS " Continuing despite missing tool: msys2 "
1115
+ prettyWarnS " Continuing despite missing tool: MSYS2. "
1098
1116
pure Nothing
1099
1117
_ -> pure Nothing
1100
1118
@@ -2065,23 +2083,51 @@ downloadAndInstallPossibleCompilers possibleCompilers si wanted versionCheck mbi
2065
2083
Right r -> pure (r, b)
2066
2084
2067
2085
getGhcKey ::
2068
- (MonadReader env m , HasPlatform env , HasGHCVariant env , MonadThrow m )
2086
+ ( HasBuildConfig env
2087
+ , HasPlatform env
2088
+ , HasGHCVariant env
2089
+ )
2069
2090
=> CompilerBuild
2070
- -> m Text
2091
+ -> RIO env Text
2071
2092
getGhcKey ghcBuild = do
2093
+ programsDir <- view $ configL. to configLocalPrograms
2072
2094
ghcVariant <- view ghcVariantL
2073
2095
platform <- view platformL
2074
- osKey <- getOSKey platform
2075
- pure $
2076
- osKey
2077
- <> T. pack (ghcVariantSuffix ghcVariant)
2078
- <> T. pack (compilerBuildSuffix ghcBuild)
2096
+ wantedComiler <- view $ buildConfigL. to (smwCompiler . bcSMWanted)
2097
+ ghcVersion <- case wantedComiler of
2098
+ WCGhc version -> pure version
2099
+ _ -> error " Impossible!"
2100
+ let suggestion = fillSep
2101
+ [ flow " To install manually the version of GHC, its root directory \
2102
+ \should be named"
2103
+ , style Dir ghcDir
2104
+ , flow " and the directory should be accompanied by a file with the \
2105
+ \same name and extension"
2106
+ , style File " .installed"
2107
+ , flow " (which marks the GHC version as installed). Those two items \
2108
+ \should be located in the subdirectory for the specified \
2109
+ \platform in Stack's directory for local tools"
2110
+ , parens (pretty programsDir) <> " ."
2111
+ ]
2112
+ ghcDir =
2113
+ " ghc"
2114
+ <> fromString variantSuffix
2115
+ <> fromString buildSuffix
2116
+ <> fromString (versionString ghcVersion)
2117
+ variantSuffix = ghcVariantSuffix ghcVariant
2118
+ buildSuffix = compilerBuildSuffix ghcBuild
2119
+ osKey <- getOSKey " GHC" suggestion platform
2120
+ pure $ osKey <> T. pack variantSuffix <> T. pack buildSuffix
2079
2121
2080
2122
getOSKey ::
2081
2123
(MonadThrow m )
2082
- => Platform
2124
+ => StyleDoc
2125
+ -- ^ Description of the tool that is being set up.
2126
+ -> StyleDoc
2127
+ -- ^ Suggestion if the platform is unsupported.
2128
+ -> Platform
2083
2129
-> m Text
2084
- getOSKey platform =
2130
+ getOSKey tool suggestion platform =
2085
2131
case platform of
2086
2132
Platform I386 Cabal. Linux -> pure " linux32"
2087
2133
Platform X86_64 Cabal. Linux -> pure " linux64"
@@ -2098,7 +2144,8 @@ getOSKey platform =
2098
2144
Platform Sparc Cabal. Linux -> pure " linux-sparc"
2099
2145
Platform AArch64 Cabal. OSX -> pure " macosx-aarch64"
2100
2146
Platform AArch64 Cabal. FreeBSD -> pure " freebsd-aarch64"
2101
- Platform arch os -> prettyThrowM $ UnsupportedSetupCombo os arch
2147
+ Platform arch os ->
2148
+ prettyThrowM $ UnsupportedSetupCombo os arch tool suggestion
2102
2149
2103
2150
downloadOrUseLocal ::
2104
2151
(HasTerm env , HasBuildConfig env )
0 commit comments