warn user if current running ghcup exec is in non-standard location
This commit is contained in:
parent
d166cc84a1
commit
aee7fa52c3
13
lib/GHCup.hs
13
lib/GHCup.hs
@ -1286,6 +1286,7 @@ rmStackVer ver = do
|
|||||||
rmGhcup :: ( MonadReader AppState m
|
rmGhcup :: ( MonadReader AppState m
|
||||||
, MonadIO m
|
, MonadIO m
|
||||||
, MonadCatch m
|
, MonadCatch m
|
||||||
|
, MonadLogger m
|
||||||
)
|
)
|
||||||
=> m ()
|
=> m ()
|
||||||
|
|
||||||
@ -1293,6 +1294,9 @@ rmGhcup = do
|
|||||||
AppState {dirs = Dirs {binDir}} <- ask
|
AppState {dirs = Dirs {binDir}} <- ask
|
||||||
let ghcupFilename = "ghcup" <> exeExt
|
let ghcupFilename = "ghcup" <> exeExt
|
||||||
let ghcupFilepath = binDir </> ghcupFilename
|
let ghcupFilepath = binDir </> ghcupFilename
|
||||||
|
currentRunningExecPath <- liftIO $ getExecutablePath
|
||||||
|
if currentRunningExecPath == ghcupFilepath
|
||||||
|
then do
|
||||||
#if defined(IS_WINDOWS)
|
#if defined(IS_WINDOWS)
|
||||||
-- since it doesn't seem possible to delete a running exec in windows
|
-- since it doesn't seem possible to delete a running exec in windows
|
||||||
-- we move it to temp dir, to be deleted at next reboot
|
-- we move it to temp dir, to be deleted at next reboot
|
||||||
@ -1305,6 +1309,15 @@ rmGhcup = do
|
|||||||
-- delete it.
|
-- delete it.
|
||||||
hideError doesNotExistErrorType $ liftIO $ rmFile ghcupFilepath
|
hideError doesNotExistErrorType $ liftIO $ rmFile ghcupFilepath
|
||||||
#endif
|
#endif
|
||||||
|
else
|
||||||
|
$logWarn $
|
||||||
|
nonStandardInstallLocationMsg currentRunningExecPath
|
||||||
|
|
||||||
|
where
|
||||||
|
nonStandardInstallLocationMsg path = T.pack $
|
||||||
|
"current ghcup is invoked from a non-standard location: \n"
|
||||||
|
<> path <>
|
||||||
|
"\n you may have to uninstall it manually."
|
||||||
|
|
||||||
rmTool :: ( MonadReader AppState m
|
rmTool :: ( MonadReader AppState m
|
||||||
, MonadLogger m
|
, MonadLogger m
|
||||||
|
Loading…
Reference in New Issue
Block a user