Skip to content

Commit eab0033

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

File tree

1 file changed

+58
-20
lines changed

1 file changed

+58
-20
lines changed

src/Stack/Setup.hs

+58-20
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 !(Path Abs Dir)
202203
| MissingDependencies ![String]
203204
| UnknownCompilerVersion
204205
!(Set.Set Text)
@@ -310,17 +311,34 @@ 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 toolDirAdvice programsDir) =
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+
<> fillSep
328+
[ flow "To install manually the version of"
329+
, tool <> ","
330+
, flow "its root directory should be named"
331+
, toolDirAdvice
332+
, flow "and the directory should be accompanied by a file with the \
333+
\same name and extension"
334+
, style File ".installed"
335+
, flow "(which marks the"
336+
, tool
337+
, flow "version as installed). Both items should be located in the \
338+
\subdirectory for the specified platform in Stack's directory \
339+
\for local tools"
340+
, parens (pretty programsDir) <> "."
341+
]
324342
pretty (MissingDependencies tools) =
325343
"[S-2126]"
326344
<> line
@@ -1081,7 +1099,11 @@ ensureMsys sopts getSetupInfo' = do
10811099
Nothing
10821100
| soptsInstallIfMissing sopts -> do
10831101
si <- runMemoized getSetupInfo'
1084-
osKey <- getOSKey platform
1102+
let msysDir = fillSep
1103+
[ style Dir "msys2-yyyymmdd"
1104+
, flow "(where yyyymmdd is the date-based version)"
1105+
]
1106+
osKey <- getOSKey "MSYS2" msysDir
10851107
config <- view configL
10861108
VersionedDownloadInfo version info <-
10871109
case Map.lookup osKey $ siMsys2 si of
@@ -1094,7 +1116,7 @@ ensureMsys sopts getSetupInfo' = do
10941116
tool
10951117
(installMsys2Windows si)
10961118
| otherwise -> do
1097-
prettyWarnS "Continuing despite missing tool: msys2"
1119+
prettyWarnS "Continuing despite missing tool: MSYS2."
10981120
pure Nothing
10991121
_ -> pure Nothing
11001122

@@ -2065,23 +2087,38 @@ downloadAndInstallPossibleCompilers possibleCompilers si wanted versionCheck mbi
20652087
Right r -> pure (r, b)
20662088

20672089
getGhcKey ::
2068-
(MonadReader env m, HasPlatform env, HasGHCVariant env, MonadThrow m)
2090+
(HasBuildConfig env, HasGHCVariant env)
20692091
=> CompilerBuild
2070-
-> m Text
2092+
-> RIO env Text
20712093
getGhcKey ghcBuild = do
20722094
ghcVariant <- view ghcVariantL
2073-
platform <- view platformL
2074-
osKey <- getOSKey platform
2075-
pure $
2076-
osKey
2077-
<> T.pack (ghcVariantSuffix ghcVariant)
2078-
<> T.pack (compilerBuildSuffix ghcBuild)
2095+
wantedComiler <- view $ buildConfigL.to (smwCompiler . bcSMWanted)
2096+
ghcVersion <- case wantedComiler of
2097+
WCGhc version -> pure version
2098+
WCGhcjs _ _ -> throwIO GhcjsNotSupported
2099+
WCGhcGit _ _ -> throwIO DownloadAndInstallCompilerError
2100+
let variantSuffix = ghcVariantSuffix ghcVariant
2101+
buildSuffix = compilerBuildSuffix ghcBuild
2102+
ghcDir = style Dir $ mconcat
2103+
[ "ghc"
2104+
, fromString variantSuffix
2105+
, fromString buildSuffix
2106+
, "-"
2107+
, fromString $ versionString ghcVersion
2108+
]
2109+
osKey <- getOSKey "GHC" ghcDir
2110+
pure $ osKey <> T.pack variantSuffix <> T.pack buildSuffix
20792111

20802112
getOSKey ::
2081-
(MonadThrow m)
2082-
=> Platform
2083-
-> m Text
2084-
getOSKey platform =
2113+
(HasConfig env, HasPlatform env)
2114+
=> StyleDoc
2115+
-- ^ Description of the tool that is being set up.
2116+
-> StyleDoc
2117+
-- ^ Description of the root directory of the tool.
2118+
-> RIO env Text
2119+
getOSKey tool toolDir = do
2120+
programsDir <- view $ configL.to configLocalPrograms
2121+
platform <- view platformL
20852122
case platform of
20862123
Platform I386 Cabal.Linux -> pure "linux32"
20872124
Platform X86_64 Cabal.Linux -> pure "linux64"
@@ -2098,7 +2135,8 @@ getOSKey platform =
20982135
Platform Sparc Cabal.Linux -> pure "linux-sparc"
20992136
Platform AArch64 Cabal.OSX -> pure "macosx-aarch64"
21002137
Platform AArch64 Cabal.FreeBSD -> pure "freebsd-aarch64"
2101-
Platform arch os -> prettyThrowM $ UnsupportedSetupCombo os arch
2138+
Platform arch os ->
2139+
prettyThrowM $ UnsupportedSetupCombo os arch tool toolDir programsDir
21022140

21032141
downloadOrUseLocal ::
21042142
(HasTerm env, HasBuildConfig env)

0 commit comments

Comments
 (0)