Skip to content

Commit 88b6128

Browse files
committed
Mark packages uninstalled before rebuilding #365
1 parent 45cc6b7 commit 88b6128

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Bug fixes:
1717

1818
* Haddock links to global packages no longer broken on Windows [#375](https://github.com/commercialhaskell/stack/issues/375)
1919
* Make flags case-insensitive [#397](https://github.com/commercialhaskell/stack/issues/397)
20+
* Mark packages uninstalled before rebuilding [#365](https://github.com/commercialhaskell/stack/issues/365)
2021

2122
## 0.1.0.0
2223

src/Stack/Build/Cache.hs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ module Stack.Build.Cache
1313
, tryGetFlagCache
1414
, deleteCaches
1515
, markExeInstalled
16+
, markExeNotInstalled
1617
, writeFlagCache
1718
, writeBuildCache
1819
, writeConfigCache
1920
, writeCabalMod
2021
) where
2122

22-
import Control.Exception.Enclosed (handleIO, tryIO)
23+
import Control.Exception.Enclosed (catchIO, handleIO, tryIO)
2324
import Control.Monad.Catch (MonadCatch, MonadThrow, catch,
2425
throwM)
2526
import Control.Monad.IO.Class
@@ -42,7 +43,8 @@ import Stack.Package
4243
import Stack.Types
4344
import System.Directory (createDirectoryIfMissing,
4445
getDirectoryContents,
45-
getModificationTime)
46+
getModificationTime,
47+
removeFile)
4648
import System.IO.Error (isDoesNotExistError)
4749

4850
-- | Directory containing files to mark an executable as installed
@@ -72,6 +74,15 @@ markExeInstalled loc ident = do
7274
-- longer exist
7375
liftIO $ writeFile fp "Installed"
7476

77+
-- | Mark the given executable as not installed
78+
markExeNotInstalled :: (MonadReader env m, HasEnvConfig env, MonadIO m, MonadThrow m)
79+
=> InstallLocation -> PackageIdentifier -> m ()
80+
markExeNotInstalled loc ident = do
81+
dir <- exeInstalledDir loc
82+
ident' <- parseRelFile $ packageIdentifierString ident
83+
let fp = toFilePath $ dir </> ident'
84+
liftIO $ catchIO (removeFile fp) (\_ -> return ())
85+
7586
-- | Stored on disk to know whether the flags have changed or any
7687
-- files have changed.
7788
data BuildCache = BuildCache

src/Stack/Build/Execute.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,7 @@ singleBuild ac@ActionContext {..} ee@ExecuteEnv {..} task@Task {..} =
619619
(cache, _neededConfig) <- ensureConfig pkgDir ee task (announce "configure") cabal cabalfp []
620620

621621
fileModTimes <- getPackageFileModTimes package cabalfp
622+
markExeNotInstalled (taskLocation task) taskProvides
622623
writeBuildCache pkgDir fileModTimes
623624

624625
announce "build"

0 commit comments

Comments
 (0)