@@ -158,7 +158,8 @@ import Stack.Types.Platform
158158 , platformOnlyRelDir )
159159import Stack.Types.Runner ( HasRunner (.. ) )
160160import Stack.Types.SetupInfo ( SetupInfo (.. ) )
161- import Stack.Types.SourceMap ( SMActual (.. ), SourceMap (.. ) )
161+ import Stack.Types.SourceMap
162+ ( SMActual (.. ), SMWanted (.. ), SourceMap (.. ) )
162163import Stack.Types.Version
163164 ( VersionCheck , stackMinorVersion , stackVersion )
164165import 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 ! ( Path Rel Dir ) ! ( 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 toolDir 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+ , pretty toolDir
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,8 @@ ensureMsys sopts getSetupInfo' = do
10811099 Nothing
10821100 | soptsInstallIfMissing sopts -> do
10831101 si <- runMemoized getSetupInfo'
1084- osKey <- getOSKey platform
1102+ msysDir <- parseRelDir " msys2-yyyymmdd"
1103+ osKey <- getOSKey " MSYS2" msysDir
10851104 config <- view configL
10861105 VersionedDownloadInfo version info <-
10871106 case Map. lookup osKey $ siMsys2 si of
@@ -1094,7 +1113,7 @@ ensureMsys sopts getSetupInfo' = do
10941113 tool
10951114 (installMsys2Windows si)
10961115 | otherwise -> do
1097- prettyWarnS " Continuing despite missing tool: msys2 "
1116+ prettyWarnS " Continuing despite missing tool: MSYS2. "
10981117 pure Nothing
10991118 _ -> pure Nothing
11001119
@@ -2065,23 +2084,37 @@ downloadAndInstallPossibleCompilers possibleCompilers si wanted versionCheck mbi
20652084 Right r -> pure (r, b)
20662085
20672086getGhcKey ::
2068- (MonadReader env m , HasPlatform env , HasGHCVariant env , MonadThrow m )
2087+ (HasBuildConfig env , HasGHCVariant env )
20692088 => CompilerBuild
2070- -> m Text
2089+ -> RIO env Text
20712090getGhcKey ghcBuild = do
20722091 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)
2092+ wantedComiler <- view $ buildConfigL. to (smwCompiler . bcSMWanted)
2093+ ghcVersion <- case wantedComiler of
2094+ WCGhc version -> pure version
2095+ WCGhcjs _ _ -> throwIO GhcjsNotSupported
2096+ WCGhcGit _ _ -> throwIO DownloadAndInstallCompilerError
2097+ let variantSuffix = ghcVariantSuffix ghcVariant
2098+ buildSuffix = compilerBuildSuffix ghcBuild
2099+ ghcDir <- parseRelDir $
2100+ " ghc"
2101+ <> variantSuffix
2102+ <> buildSuffix
2103+ <> " -"
2104+ <> versionString ghcVersion
2105+ osKey <- getOSKey " GHC" ghcDir
2106+ pure $ osKey <> T. pack variantSuffix <> T. pack buildSuffix
20792107
20802108getOSKey ::
2081- (MonadThrow m )
2082- => Platform
2083- -> m Text
2084- getOSKey platform =
2109+ (HasConfig env , HasPlatform env )
2110+ => StyleDoc
2111+ -- ^ Description of the tool that is being set up.
2112+ -> Path Rel Dir
2113+ -- ^ Root directory of tool.
2114+ -> RIO env Text
2115+ getOSKey tool toolDir = do
2116+ programsDir <- view $ configL. to configLocalPrograms
2117+ platform <- view platformL
20852118 case platform of
20862119 Platform I386 Cabal. Linux -> pure " linux32"
20872120 Platform X86_64 Cabal. Linux -> pure " linux64"
@@ -2098,7 +2131,8 @@ getOSKey platform =
20982131 Platform Sparc Cabal. Linux -> pure " linux-sparc"
20992132 Platform AArch64 Cabal. OSX -> pure " macosx-aarch64"
21002133 Platform AArch64 Cabal. FreeBSD -> pure " freebsd-aarch64"
2101- Platform arch os -> prettyThrowM $ UnsupportedSetupCombo os arch
2134+ Platform arch os ->
2135+ prettyThrowM $ UnsupportedSetupCombo os arch tool toolDir programsDir
21022136
21032137downloadOrUseLocal ::
21042138 (HasTerm env , HasBuildConfig env )
0 commit comments