diff --git a/cabal-install/Distribution/Client/Sandbox.hs b/cabal-install/Distribution/Client/Sandbox.hs index 68b113c17535e4b668b1d93f56f0b5eeec7a6172..38c8d51bec10bb39fce0256d083160ded65f12b4 100644 --- a/cabal-install/Distribution/Client/Sandbox.hs +++ b/cabal-install/Distribution/Client/Sandbox.hs @@ -498,7 +498,7 @@ reinstallAddSourceDeps verbosity config configFlags configExFlags -- | Check if a sandbox is present and call @reinstallAddSourceDeps@ in that -- case. maybeReinstallAddSourceDeps :: Verbosity -> Flag (Maybe Int) -> GlobalFlags - -> IO (UseSandbox, WereDepsReinstalled) + -> IO (UseSandbox, WereDepsReinstalled) maybeReinstallAddSourceDeps verbosity numJobsFlag globalFlags' = do currentDir <- getCurrentDirectory pkgEnvType <- classifyPackageEnvironment currentDir diff --git a/cabal-install/Main.hs b/cabal-install/Main.hs index f1f192f69e37511ee01b4ad9da585026ab5e7973..89f80e0e4cc3199225d535d21a9198348202a651 100644 --- a/cabal-install/Main.hs +++ b/cabal-install/Main.hs @@ -73,7 +73,7 @@ import Distribution.Client.Sandbox (sandboxInit ,dumpPackageEnvironment ,UseSandbox(..) - ,isUseSandbox, whenUsingSandbox + ,whenUsingSandbox ,ForceGlobalInstall(..) ,maybeForceGlobalInstall ,loadConfigOrSandboxConfig @@ -227,9 +227,10 @@ configureAction (configFlags, configExFlags) extraArgs globalFlags = do globalFlags' = savedGlobalFlags config `mappend` globalFlags (comp, platform, conf) <- configCompilerAux configFlags' - -- If this a sandbox and the user has set the -w option, we may need to create - -- a sandbox-local package DB for this compiler and rewrite the - -- 'with-compiler' and 'package-db' fields in the cabal.sandbox.config file. + -- If we're working inside a sandbox and the user has set the -w option, we + -- may need to create a sandbox-local package DB for this compiler, rewrite + -- the 'with-compiler' and 'package-db' fields in the 'cabal.sandbox.config' + -- file and add a timestamp record for this compiler to the timestamp file. let configFlags'' = case useSandbox of NoSandbox -> configFlags' (UseSandbox sandboxDir) -> setPackageDB sandboxDir @@ -239,8 +240,6 @@ configureAction (configFlags, configExFlags) extraArgs globalFlags = do initPackageDBIfNeeded verbosity configFlags'' comp conf maybeUpdateSandboxConfig verbosity config configFlags'' - -- If we've switched to a new compiler, we may need to add a timestamp - -- record for this compiler to the timestamp file. indexFile <- tryGetIndexFilePath config maybeAddCompilerTimestampRecord verbosity sandboxDir indexFile (compilerId comp) platform @@ -466,26 +465,27 @@ installAction (configFlags, configExFlags, installFlags, haddockFlags) (comp, platform, conf) <- configCompilerAux' configFlags' -- If we're working inside a sandbox and the user has set the -w option, we - -- may need to create a sandbox-local package DB for this compiler. + -- may need to create a sandbox-local package DB for this compiler and add a + -- timestamp record for this compiler to the timestamp file. let configFlags'' = case useSandbox of NoSandbox -> configFlags' (UseSandbox sandboxDir) -> setPackageDB sandboxDir comp platform configFlags' - when (isUseSandbox useSandbox) $ - initPackageDBIfNeeded verbosity configFlags'' comp conf - -- If we're working inside a sandbox and "." is among the targets, we should - -- reinstall add-source dependencies for this compiler. whenUsingSandbox useSandbox $ \sandboxDir -> do - -- If the 'install' command was invoked with '-w', we may need to add a - -- timestamp record for this compiler to the timestamp file. + initPackageDBIfNeeded verbosity configFlags'' comp conf + indexFile <- tryGetIndexFilePath config maybeAddCompilerTimestampRecord verbosity sandboxDir indexFile (compilerId comp) platform + -- If "." is among the targets, we should reinstall add-source dependencies + -- for this compiler and maybe rewrite the 'with-compiler' and 'package-db' + -- fields in the 'cabal.sandbox.config' file. when (null targets || (UserTargetLocalDir ".") `elem` targets) $ do - -- 'install .' always runs 'configure', so we don't need to check whether - -- we need to reconfigure. + maybeUpdateSandboxConfig verbosity config configFlags'' + -- 'install .' always runs 'configure', so we don't need to force + -- reconfigure ourselves. _ <- reinstallAddSourceDeps verbosity config configFlags'' configExFlags' installFlags' globalFlags' sandboxDir