Skip to content

Commit c45c924

Browse files
authored
Merge pull request #5825 from mpilgrem/uninstall
Make `stack uninstall` informative
2 parents cfcd04c + 846dba7 commit c45c924

File tree

4 files changed

+49
-30
lines changed

4 files changed

+49
-30
lines changed

ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Other enhancements:
3737
* Add the possibility of a `sh` script to customise fully GHC installation. See
3838
[#5585](https://github.com/commercialhaskell/stack/pull/5585)
3939
* `tools` subcommand added to `stack ls`, to list stack's installed tools.
40+
* `stack uninstall` shows how to uninstall Stack.
4041

4142
Bug fixes:
4243

doc/GUIDE.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,18 +1175,17 @@ On Windows (with PowerShell):
11751175
-a--- 25/02/2022 11:39 PM 9 msys2-20210604.installed
11761176

11771177
While we're talking about paths, to wipe our Stack install completely, here's
1178-
what needs to be removed:
1179-
1180-
1. Delete the Stack root folder (see `stack path --stack-root`, before you
1181-
uninstall).
1182-
2. On Windows, delete the folder containing Stack's tools (see
1183-
`stack path --programs`, before you uninstall), which is located outside of
1184-
the Stack root folder
1185-
3. Delete the `stack` executable (see `which stack`, on Unix-like operating
1178+
what typically needs to be removed:
1179+
1180+
1. the Stack root folder (see `stack path --stack-root`, before you uninstall);
1181+
2. on Windows, the folder containing Stack's tools (see `stack path --programs`,
1182+
before you uninstall), which is located outside of the Stack root folder; and
1183+
3. the `stack` executable file (see `which stack`, on Unix-like operating
11861184
systems, or `where.exe stack`, on Windows).
11871185

1188-
You may also want to delete ``.stack-work`` folders in any Haskell projects that
1189-
you have built using Stack.
1186+
You may also want to delete `.stack-work` folders in any Haskell projects that
1187+
you have built using Stack. The `stack uninstall` command provides information
1188+
about how to uninstall Stack.
11901189

11911190
## The `stack exec` command
11921191

doc/README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -231,15 +231,14 @@ found in the current directory.
231231

232232
## How to uninstall
233233

234-
To uninstall Stack, it should be sufficient to:
235-
236-
1. Delete the Stack root folder (see `stack path --stack-root`, before you
237-
uninstall).
238-
2. On Windows, delete the folder containing Stack's tools (see
239-
`stack path --programs`, before you uninstall), which is located outside of
240-
the Stack root folder
241-
3. Delete the `stack` executable (see `which stack`, on Unix-like operating
234+
To uninstall Stack, it should be sufficient to delete:
235+
236+
1. the Stack root folder (see `stack path --stack-root`, before you uninstall);
237+
2. on Windows, the folder containing Stack's tools (see `stack path --programs`,
238+
before you uninstall), which is located outside of the Stack root folder; and
239+
3. the `stack` executable file (see `which stack`, on Unix-like operating
242240
systems, or `where.exe stack`, on Windows).
243241

244242
You may also want to delete ``.stack-work`` folders in any Haskell projects that
245-
you have built using Stack.
243+
you have built using Stack. The `stack uninstall` command provides information
244+
about how to uninstall Stack.

src/main/Main.hs

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,11 @@ commandLineHandler currentDir progName isInterpreter = complicatedOptions
197197
buildCmd
198198
(buildOptsParser Install)
199199
addCommand' "uninstall"
200-
"DEPRECATED: This command performs no actions, and is present for documentation only"
200+
(unwords [ "Show how to uninstall Stack. This command does not"
201+
, "itself uninstall Stack."
202+
] )
201203
uninstallCmd
202-
(many $ strArgument $ metavar "IGNORED")
204+
(pure())
203205
addBuildCommand' "test"
204206
"Shortcut for 'build --test'"
205207
buildCmd
@@ -575,15 +577,33 @@ buildCmd opts = do
575577
Install -> set (globalOptsBuildOptsMonoidL.buildOptsMonoidInstallExesL) (Just True)
576578
Build -> id -- Default case is just Build
577579

578-
uninstallCmd :: [String] -> RIO Runner ()
579-
uninstallCmd _ = do
580-
prettyErrorL
581-
[ flow "stack does not manage installations in global locations."
582-
, flow "The only global mutation stack performs is executable copying."
583-
, flow "For the default executable destination, please run"
584-
, PP.style Shell "stack path --local-bin"
585-
]
586-
liftIO exitFailure
580+
-- | Display help for the uninstall command.
581+
uninstallCmd :: () -> RIO Runner ()
582+
uninstallCmd () = withConfig NoReexec $ do
583+
stackRoot <- view stackRootL
584+
programsDir <- view $ configL.to configLocalProgramsBase
585+
localBinDir <- view $ configL.to configLocalBin
586+
let toStyleDoc = PP.style Dir . fromString . toFilePath
587+
stackRoot' = toStyleDoc stackRoot
588+
programsDir' = toStyleDoc programsDir
589+
localBinDir' = toStyleDoc localBinDir
590+
prettyInfo $ vsep
591+
[ flow "To uninstall Stack, it should be sufficient to delete:"
592+
, hang 4 $ fillSep [flow "(1) the directory containing Stack's tools",
593+
"(" <> softbreak <> programsDir' <> softbreak <> ");"]
594+
, hang 4 $ fillSep [flow "(2) the Stack root directory",
595+
"(" <> softbreak <> stackRoot' <> softbreak <> ");", "and"]
596+
, hang 4 $ fillSep [flow "(3) the 'stack' executable file (see the output",
597+
flow "of command", howToFindStack <> ",", flow "if Stack is on the PATH;",
598+
flow "Stack is often installed in", localBinDir' <> softbreak <> ")."]
599+
, fillSep [flow "You may also want to delete", PP.style File ".stack-work",
600+
flow "directories in any Haskell projects that you have built."]
601+
]
602+
where
603+
styleShell = PP.style Shell
604+
howToFindStack
605+
| osIsWindows = styleShell "where.exe stack"
606+
| otherwise = styleShell "which stack"
587607

588608
-- | Unpack packages to the filesystem
589609
unpackCmd :: ([String], Maybe Text) -> RIO Runner ()

0 commit comments

Comments
 (0)