From 1dfe5cfecf1fb9871c9e1de22046215a2b4af785 Mon Sep 17 00:00:00 2001 From: Arjun Kathuria Date: Mon, 28 Jun 2021 13:56:20 +0530 Subject: [PATCH] updates path equating (which may fail) in "rmGhcup" function. --- lib/GHCup.hs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/GHCup.hs b/lib/GHCup.hs index dcad07e..cc1a77e 100644 --- a/lib/GHCup.hs +++ b/lib/GHCup.hs @@ -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 <>