updates path equating (which may fail) in "rmGhcup" function.

This commit is contained in:
Arjun Kathuria 2021-06-28 13:56:20 +05:30
parent 8e4550657e
commit 1dfe5cfecf
1 changed files with 20 additions and 1 deletions

View File

@ -1294,8 +1294,23 @@ rmGhcup = do
AppState {dirs = Dirs {binDir}} <- ask
let ghcupFilename = "ghcup" <> exeExt
let ghcupFilepath = binDir </> ghcupFilename
currentRunningExecPath <- liftIO $ getExecutablePath
if currentRunningExecPath == ghcupFilepath
-- if paths do no exist, warn user, and continue to compare them, as is,
-- which should eventually fail and result in a non-standard install warning
p1 <- handleIO' doesNotExistErrorType
(handlePathNotPresent currentRunningExecPath)
(liftIO $ canonicalizePath currentRunningExecPath)
p2 <- handleIO' doesNotExistErrorType
(handlePathNotPresent ghcupFilename)
(liftIO $ canonicalizePath ghcupFilename)
let areEqualPaths = equalFilePath p1 p2
if areEqualPaths
then
do
#if defined(IS_WINDOWS)
@ -1315,6 +1330,10 @@ rmGhcup = do
nonStandardInstallLocationMsg currentRunningExecPath
where
handlePathNotPresent fp _err = do
$logWarn $ "Error: The path does not exist, " <> T.pack fp
pure fp
nonStandardInstallLocationMsg path = T.pack $
"current ghcup is invoked from a non-standard location: \n"
<> path <>