diff --git a/ChangeLog.md b/ChangeLog.md index 535cfea064..57c641cd9a 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -43,6 +43,7 @@ Other enhancements: `--work-dir` option is not a valid relative path. * Stack will use the value of the `GH_TOKEN`, or `GITHUB_TOKEN`, environment variable as credentials to authenticate its GitHub REST API requests. +* `stack uninstall` also shows how to uninstall Stack-supplied tools. Bug fixes: diff --git a/doc/maintainers/stack_errors.md b/doc/maintainers/stack_errors.md index 5503e0cd10..7adc232597 100644 --- a/doc/maintainers/stack_errors.md +++ b/doc/maintainers/stack_errors.md @@ -5,7 +5,7 @@ In connection with considering Stack's support of the [Haskell Error Index](https://errors.haskell.org/) initiative, this page seeks to take stock of the errors that Stack itself can raise, by reference to the -`master` branch of the Stack repository. Last updated: 2023-04-19. +`master` branch of the Stack repository. Last updated: 2023-04-22. * `Main.main`: catches exceptions from action `commandLineHandler`. @@ -272,7 +272,6 @@ to take stock of the errors that Stack itself can raise, by reference to the [S-5308] | MSYS2NotFound Text [S-5127] | UnwantedCompilerVersion [S-1540] | UnwantedArchitecture - [S-9953] | SandboxedCompilerNotFound [S-8668] | GHCInfoNotValidUTF8 UnicodeException [S-4878] | GHCInfoNotListOfPairs [S-2965] | GHCInfoMissingGlobalPackageDB @@ -306,6 +305,7 @@ to take stock of the errors that Stack itself can raise, by reference to the [S-7441] = GHCInstallFailed SomeException StyleDoc String [String] (Path Abs Dir) (Path Abs Dir) (Path Abs Dir) [S-2476] | InvalidGhcAt (Path Abs File) SomeException [S-4764] | ExecutableNotFound [Path Abs File] + [S-9953] | SandboxedCompilerNotFound [String] [Path Abs Dir] ~~~ - `Stack.Storage.User.StorageUserException` diff --git a/doc/uninstall_command.md b/doc/uninstall_command.md index 2f387a5182..afe34465ed 100644 --- a/doc/uninstall_command.md +++ b/doc/uninstall_command.md @@ -6,5 +6,6 @@ stack uninstall ~~~ -`stack uninstall` provides information about how to uninstall Stack. It does not -itself uninstall Stack. +`stack uninstall` provides information about how to uninstall Stack or a +Stack-supplied tool (such as GHC or, on Windows, MSYS2). It does not +itself uninstall Stack or a Stack-supplied tool. diff --git a/src/Stack/Setup.hs b/src/Stack/Setup.hs index 99a55dad0f..1fd44d3459 100644 --- a/src/Stack/Setup.hs +++ b/src/Stack/Setup.hs @@ -179,7 +179,6 @@ data SetupException | MSYS2NotFound Text | UnwantedCompilerVersion | UnwantedArchitecture - | SandboxedCompilerNotFound | GHCInfoNotValidUTF8 UnicodeException | GHCInfoNotListOfPairs | GHCInfoMissingGlobalPackageDB @@ -282,9 +281,6 @@ instance Exception SetupException where displayException UnwantedArchitecture = "Error: [S-1540]\n" ++ "Not the architecture we want." - displayException SandboxedCompilerNotFound = - "Error: [S-9953]\n" - ++ "Could not find sandboxed compiler." displayException (GHCInfoNotValidUTF8 e) = concat [ "Error: [S-8668]\n" , "GHC info is not valid UTF-8: " @@ -403,15 +399,16 @@ instance Exception SetupException where -- "Stack.Setup" module data SetupPrettyException = GHCInstallFailed - SomeException - String - String - [String] - (Path Abs Dir) - (Path Abs Dir) - (Path Abs Dir) - | InvalidGhcAt (Path Abs File) SomeException - | ExecutableNotFound [Path Abs File] + !SomeException + !String + !String + ![String] + !(Path Abs Dir) + !(Path Abs Dir) + !(Path Abs Dir) + | InvalidGhcAt !(Path Abs File) !SomeException + | ExecutableNotFound ![Path Abs File] + | SandboxedCompilerNotFound ![String] ![Path Abs Dir] deriving (Show, Typeable) instance Pretty SetupPrettyException where @@ -465,6 +462,26 @@ instance Pretty SetupPrettyException where <> flow "Stack could not find any of the following executables:" <> line <> bulletedList (map pretty toTry) + pretty (SandboxedCompilerNotFound names fps) = + "[S-9953]" + <> line + <> fillSep + ( ( flow "Stack could not find the sandboxed compiler. It looked for \ + \one named one of:" + : mkNarrativeList Nothing False + ( map fromString names :: [StyleDoc] ) + ) + <> ( flow "However, it could not find any on one of the paths:" + : mkNarrativeList Nothing False fps + ) + ) + <> blankLine + <> fillSep + [ flow "Perhaps a previously-installed compiler was not completely \ + \uninstalled. For further information about uninstalling \ + \tools, see the output of" + , style Shell (flow "stack uninstall") <> "." + ] instance Exception SetupPrettyException @@ -1149,7 +1166,7 @@ ensureSandboxedCompiler sopts getSetupInfo' = do logError $ "Could not find it on the paths " <> displayShow (edBins paths) - throwIO SandboxedCompilerNotFound + prettyThrowIO $ SandboxedCompilerNotFound names (edBins paths) loop (x:xs) = do res <- liftIO $ D.findExecutablesInDirectories (map toFilePath (edBins paths)) x diff --git a/src/Stack/Uninstall.hs b/src/Stack/Uninstall.hs index 05306169c3..b4f114c3bd 100644 --- a/src/Stack/Uninstall.hs +++ b/src/Stack/Uninstall.hs @@ -28,21 +28,57 @@ uninstallCmd () = withConfig NoReexec $ do globalConfig' = toStyleDoc globalConfig programsDir' = toStyleDoc programsDir localBinDir' = toStyleDoc localBinDir - prettyInfo $ vsep - [ flow "To uninstall Stack, it should be sufficient to delete:" - , hang 4 $ fillSep [flow "(1) the directory containing Stack's tools", - "(" <> softbreak <> programsDir' <> softbreak <> ");"] - , hang 4 $ fillSep [flow "(2) the Stack root directory", - "(" <> softbreak <> stackRoot' <> softbreak <> ");"] - , hang 4 $ fillSep [flow "(3) if different, the directory containing ", - flow "Stack's global YAML configuration file", - "(" <> softbreak <> globalConfig' <> softbreak <> ");", "and"] - , hang 4 $ fillSep [flow "(4) the 'stack' executable file (see the output", - flow "of command", howToFindStack <> ",", flow "if Stack is on the PATH;", - flow "Stack is often installed in", localBinDir' <> softbreak <> ")."] - , fillSep [flow "You may also want to delete", style File ".stack-work", - flow "directories in any Haskell projects that you have built."] - ] + prettyInfo $ + vsep + [ flow "To uninstall Stack, it should be sufficient to delete:" + , hang 4 $ fillSep + [ flow "(1) the directory containing Stack's tools" + , "(" <> softbreak <> programsDir' <> softbreak <> ");" + ] + , hang 4 $ fillSep + [ flow "(2) the Stack root directory" + , "(" <> softbreak <> stackRoot' <> softbreak <> ");" + ] + , hang 4 $ fillSep + [ flow "(3) if different, the directory containing " + , flow "Stack's global YAML configuration file" + , parens globalConfig' <> ";" + , "and" + ] + , hang 4 $ fillSep + [ flow "(4) the 'stack' executable file (see the output" + , flow "of command" + , howToFindStack <> "," + , flow "if Stack is on the PATH;" + , flow "Stack is often installed in" + , localBinDir' <> softbreak <> ")." + ] + , fillSep + [flow "You may also want to delete" + , style File ".stack-work" + , flow "directories in any Haskell projects that you have built." + ] + ] + <> blankLine + <> vsep + [ fillSep + [ flow "To uninstall completely a Stack-supplied tool (such as \ + \GHC or, on Windows, MSYS2), delete from Stack's tools \ + \directory" + , parens programsDir' <> ":" + ] + , hang 4 $ fillSep + [ flow "(1) the tool's subdirectory;" + ] + , hang 4 $ fillSep + [ flow "(2) the tool's archive file" + , parens (style File ".tar.xz") <> "; and" + ] + , hang 4 $ fillSep + [ flow "(3) the file marking that the tool is installed" + , parens (style File ".installed") <> "." + ] + ] where styleShell = style Shell howToFindStack diff --git a/src/main/Stack/CLI.hs b/src/main/Stack/CLI.hs index e6e3447d86..eb929f8bd6 100644 --- a/src/main/Stack/CLI.hs +++ b/src/main/Stack/CLI.hs @@ -451,8 +451,8 @@ commandLineHandler currentDir progName isInterpreter = uninstall = addCommand' "uninstall" - "Show how to uninstall Stack. This command does not itself uninstall \ - \Stack." + "Show how to uninstall Stack or a Stack-supplied tool. This command does \ + \not itself uninstall Stack or a Stack-supplied tool." uninstallCmd (pure ())