Skip to content

Commit ef8d390

Browse files
committed
Re #6379 Better information about manual installation
1 parent f75549f commit ef8d390

File tree

1 file changed

+64
-17
lines changed

1 file changed

+64
-17
lines changed

src/Stack/Setup.hs

+64-17
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ import Stack.Types.Platform
158158
, platformOnlyRelDir )
159159
import Stack.Types.Runner ( HasRunner (..) )
160160
import Stack.Types.SetupInfo ( SetupInfo (..) )
161-
import Stack.Types.SourceMap ( SMActual (..), SourceMap (..) )
161+
import Stack.Types.SourceMap
162+
( SMActual (..), SMWanted (..), SourceMap (..) )
162163
import Stack.Types.Version
163164
( VersionCheck, stackMinorVersion, stackVersion )
164165
import Stack.Types.VersionedDownloadInfo
@@ -198,7 +199,7 @@ data SetupPrettyException
198199
| InvalidGhcAt !(Path Abs File) !SomeException
199200
| ExecutableNotFound ![Path Abs File]
200201
| SandboxedCompilerNotFound ![String] ![Path Abs Dir]
201-
| UnsupportedSetupCombo !OS !Arch
202+
| UnsupportedSetupCombo !OS !Arch !StyleDoc !StyleDoc
202203
| MissingDependencies ![String]
203204
| UnknownCompilerVersion
204205
!(Set.Set Text)
@@ -310,17 +311,20 @@ instance Pretty SetupPrettyException where
310311
\tools, see the output of"
311312
, style Shell (flow "stack uninstall") <> "."
312313
]
313-
pretty (UnsupportedSetupCombo os arch) =
314+
pretty (UnsupportedSetupCombo os arch tool suggestion) =
314315
"[S-1852]"
315316
<> line
316317
<> 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"
319321
, style Shell (pretty os)
320322
, "and architecture"
321323
, style Shell (pretty arch) <> "."
322324
, flow "Please install manually."
323325
]
326+
<> blankLine
327+
<> suggestion
324328
pretty (MissingDependencies tools) =
325329
"[S-2126]"
326330
<> line
@@ -1081,7 +1085,21 @@ ensureMsys sopts getSetupInfo' = do
10811085
Nothing
10821086
| soptsInstallIfMissing sopts -> do
10831087
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
10851103
config <- view configL
10861104
VersionedDownloadInfo version info <-
10871105
case Map.lookup osKey $ siMsys2 si of
@@ -1094,7 +1112,7 @@ ensureMsys sopts getSetupInfo' = do
10941112
tool
10951113
(installMsys2Windows si)
10961114
| otherwise -> do
1097-
prettyWarnS "Continuing despite missing tool: msys2"
1115+
prettyWarnS "Continuing despite missing tool: MSYS2."
10981116
pure Nothing
10991117
_ -> pure Nothing
11001118

@@ -2065,23 +2083,51 @@ downloadAndInstallPossibleCompilers possibleCompilers si wanted versionCheck mbi
20652083
Right r -> pure (r, b)
20662084

20672085
getGhcKey ::
2068-
(MonadReader env m, HasPlatform env, HasGHCVariant env, MonadThrow m)
2086+
( HasBuildConfig env
2087+
, HasPlatform env
2088+
, HasGHCVariant env
2089+
)
20692090
=> CompilerBuild
2070-
-> m Text
2091+
-> RIO env Text
20712092
getGhcKey ghcBuild = do
2093+
programsDir <- view $ configL.to configLocalPrograms
20722094
ghcVariant <- view ghcVariantL
20732095
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
20792121

20802122
getOSKey ::
20812123
(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
20832129
-> m Text
2084-
getOSKey platform =
2130+
getOSKey tool suggestion platform =
20852131
case platform of
20862132
Platform I386 Cabal.Linux -> pure "linux32"
20872133
Platform X86_64 Cabal.Linux -> pure "linux64"
@@ -2098,7 +2144,8 @@ getOSKey platform =
20982144
Platform Sparc Cabal.Linux -> pure "linux-sparc"
20992145
Platform AArch64 Cabal.OSX -> pure "macosx-aarch64"
21002146
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
21022149

21032150
downloadOrUseLocal ::
21042151
(HasTerm env, HasBuildConfig env)

0 commit comments

Comments
 (0)