@@ -1957,12 +1957,16 @@ downloadStackExe platforms0 archiveInfo destDir checkPath testExe = do
19571957
19581958 platform <- view platformL
19591959
1960+ -- We need to call getExecutablePath before we overwrite the
1961+ -- currently running binary: after that, Linux will append
1962+ -- (deleted) to the filename.
1963+ currExe <- liftIO getExecutablePath
1964+
19601965 liftIO $ do
19611966 setFileExecutable (toFilePath tmpFile)
19621967
19631968 testExe tmpFile
19641969
1965- currExe <- getExecutablePath
19661970 case platform of
19671971 Platform _ Cabal. Windows | FP. equalFilePath (toFilePath destFile) currExe -> do
19681972 old <- parseAbsFile (toFilePath destFile ++ " .old" )
@@ -1975,7 +1979,7 @@ downloadStackExe platforms0 archiveInfo destDir checkPath testExe = do
19751979
19761980 logInfo $ " New stack executable available at " <> fromString (toFilePath destFile)
19771981
1978- when checkPath $ performPathChecking destFile
1982+ when checkPath $ performPathChecking destFile currExe
19791983 `catchAny` (logError . displayShow)
19801984 where
19811985
@@ -2034,9 +2038,9 @@ downloadStackExe platforms0 archiveInfo destDir checkPath testExe = do
20342038performPathChecking
20352039 :: HasConfig env
20362040 => Path Abs File -- ^ location of the newly downloaded file
2041+ -> String -- ^ currently running executable
20372042 -> RIO env ()
2038- performPathChecking newFile = do
2039- executablePath <- liftIO getExecutablePath
2043+ performPathChecking newFile executablePath = do
20402044 executablePath' <- parseAbsFile executablePath
20412045 unless (toFilePath newFile == executablePath) $ do
20422046 logInfo $ " Also copying stack executable to " <> fromString executablePath
0 commit comments