From 177d31dc2b2a58c24ccb96e6c106f9ed1ef0ec6f Mon Sep 17 00:00:00 2001 From: Michael Sloan Date: Sun, 11 Jun 2017 15:59:55 -0700 Subject: [PATCH] When extracting local GHC from tarball on windows, use temp dir #3188 --- ChangeLog.md | 3 +++ src/Stack/Setup.hs | 15 ++++----------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 3847cb4424..7b2a69e290 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -215,6 +215,9 @@ Other enhancements: on the PATH or shadowed by another entry. * Allow running tests on tarball created by sdist and upload [#717](https://github.com/commercialhaskell/stack/issues/717). +* For filesystem setup-info paths, it's no longer assumed that the + directory is writable, instead a temp dir is used. See + [#3188](https://github.com/commercialhaskell/stack/issues/3188). Bug fixes: diff --git a/src/Stack/Setup.hs b/src/Stack/Setup.hs index bf7785d1b9..6876e3e471 100644 --- a/src/Stack/Setup.hs +++ b/src/Stack/Setup.hs @@ -1369,26 +1369,19 @@ withUnpackedTarball7z name si archiveFile archiveType msrcDir destDir = do TarGz -> return ".gz" _ -> throwString $ name ++ " must be a tarball file" tarFile <- - case T.stripSuffix suffix $ T.pack $ toFilePath archiveFile of + case T.stripSuffix suffix $ T.pack $ toFilePath (filename archiveFile) of Nothing -> throwString $ "Invalid " ++ name ++ " filename: " ++ show archiveFile - Just x -> parseAbsFile $ T.unpack x + Just x -> parseRelFile $ T.unpack x run7z <- setup7z si let tmpName = toFilePathNoTrailingSep (dirname destDir) ++ "-tmp" ensureDir (parent destDir) withRunInIO $ \run -> withTempDir (parent destDir) tmpName $ \tmpDir -> run $ do liftIO $ ignoringAbsence (removeDirRecur destDir) - run7z (parent archiveFile) archiveFile - run7z tmpDir tarFile + run7z tmpDir archiveFile + run7z tmpDir (tmpDir tarFile) absSrcDir <- case msrcDir of Just srcDir -> return $ tmpDir srcDir Nothing -> expectSingleUnpackedDir archiveFile tmpDir - removeFile tarFile `catchIO` \e -> - logWarn (T.concat - [ "Exception when removing " - , T.pack $ toFilePath tarFile - , ": " - , T.pack $ show e - ]) renameDir absSrcDir destDir expectSingleUnpackedDir :: (MonadIO m, MonadThrow m) => Path Abs File -> Path Abs Dir -> m (Path Abs Dir)