diff --git a/lib/GHCup/Download.hs b/lib/GHCup/Download.hs index 9b5e5490..8de0b023 100644 --- a/lib/GHCup/Download.hs +++ b/lib/GHCup/Download.hs @@ -317,7 +317,7 @@ getDownloadInfo' t v = do without_distro = distro_preview (set _Linux UnknownLinux) (const Nothing) maybe - (throwE NoDownload) + (throwE $ NoDownload (Just v)) pure (case p of -- non-musl won't work on alpine diff --git a/lib/GHCup/Errors.hs b/lib/GHCup/Errors.hs index 4fb29b2b..f78d67e4 100644 --- a/lib/GHCup/Errors.hs +++ b/lib/GHCup/Errors.hs @@ -206,12 +206,18 @@ instance HFErrorProject NoCompatiblePlatform where eDesc _ = "No compatible platform could be found" -- | Unable to find a download for the requested version/distro. -data NoDownload = NoDownload +data NoDownload = NoDownload (Maybe GHCTargetVersion) deriving Show instance Pretty NoDownload where - pPrint NoDownload = + pPrint (NoDownload Nothing) = text (eDesc (Proxy :: Proxy NoDownload)) + pPrint (NoDownload (Just tver@(GHCTargetVersion mtarget vv))) + | (Just target) <- mtarget + , target `elem` (T.pack . prettyShow <$> enumFromTo (minBound :: Tool) (maxBound :: Tool)) + = text $ "Unable to find a download for " <> T.unpack (tVerToText tver) <> "\n" + <> "Perhaps you meant: 'ghcup " <> T.unpack target <> " " <> T.unpack (prettyVer vv) <> "'" + | otherwise = text $ "Unable to find a download for " <> T.unpack (tVerToText tver) instance HFErrorProject NoDownload where eBase _ = 10 diff --git a/lib/GHCup/GHC.hs b/lib/GHCup/GHC.hs index 26633704..35fc9025 100644 --- a/lib/GHCup/GHC.hs +++ b/lib/GHCup/GHC.hs @@ -125,7 +125,7 @@ testGHCVer ver addMakeArgs = do dlInfo <- preview (ix GHC % ix ver % viTestDL % _Just) dls - ?? NoDownload + ?? NoDownload (Just ver) liftE $ testGHCBindist dlInfo ver addMakeArgs @@ -260,7 +260,7 @@ fetchGHCSrc v mfp = do GHCupInfo { _ghcupDownloads = dls } <- lift getGHCupInfo dlInfo <- preview (ix GHC % ix v % viSourceDL % _Just) dls - ?? NoDownload + ?? NoDownload (Just v) liftE $ downloadCached' dlInfo Nothing mfp @@ -827,9 +827,10 @@ compileGHC targetGhc crossTarget ov bstrap jobs mbuildConfig patches aargs build lift $ logDebug $ "Requested to compile: " <> prettyVer ver <> " with " <> either prettyVer T.pack bstrap -- download source tarball + let tver = mkTVer ver dlInfo <- - preview (ix GHC % ix (mkTVer ver) % viSourceDL % _Just) dls - ?? NoDownload + preview (ix GHC % ix tver % viSourceDL % _Just) dls + ?? NoDownload (Just tver) dl <- liftE $ downloadCached dlInfo Nothing -- unpack @@ -1303,7 +1304,7 @@ compileGHC targetGhc crossTarget ov bstrap jobs mbuildConfig patches aargs build bghc = case bstrap of Right g -> g - Left bver -> ("ghc-" <> (T.unpack . prettyVer $ bver) <> exeExt) + Left bver -> "ghc-" <> (T.unpack . prettyVer $ bver) <> exeExt diff --git a/lib/GHCup/HLS.hs b/lib/GHCup/HLS.hs index 744ba547..5605a3bd 100644 --- a/lib/GHCup/HLS.hs +++ b/lib/GHCup/HLS.hs @@ -370,7 +370,7 @@ compileHLS targetHLS ghcs jobs ov installDir cabalProject cabalProjectLocal upda -- download source tarball dlInfo <- preview (ix HLS % ix (mkTVer tver) % viSourceDL % _Just) dls - ?? NoDownload + ?? NoDownload (Just (mkTVer tver)) dl <- liftE $ downloadCached dlInfo Nothing -- unpack diff --git a/lib/GHCup/Utils.hs b/lib/GHCup/Utils.hs index 5f0e7f20..19d32034 100644 --- a/lib/GHCup/Utils.hs +++ b/lib/GHCup/Utils.hs @@ -1212,7 +1212,7 @@ ensureGlobalTools (GHCupInfo _ _ gTools) <- lift getGHCupInfo dirs <- lift getDirs shimDownload <- liftE $ lE @_ @'[NoDownload] - $ maybe (Left NoDownload) Right $ Map.lookup ShimGen gTools + $ maybe (Left (NoDownload Nothing)) Right $ Map.lookup ShimGen gTools let dl = downloadCached' shimDownload (Just "gs.exe") Nothing void $ (\DigestError{} -> do lift $ logWarn "Digest doesn't match, redownloading gs.exe..."