From ca728dd5dca3b5dc6c90bd8223ccff9616399a4e Mon Sep 17 00:00:00 2001 From: Emanuel Borsboom Date: Tue, 5 Mar 2019 17:13:38 -0800 Subject: [PATCH 1/3] Docker: fix pull missing images with `--docker-auto-pull` (fixes #4598) --- ChangeLog.md | 4 +++- src/Stack/Docker.hs | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index ec3ec43276..f85d756ef8 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -17,7 +17,7 @@ Other enhancements: - Document the way stack interacts with the Cabal library. * `get-stack` script now works on Windows CI machines of Appveyor, Travis and Azure Pipelines. See - [#4535](https://github.com/commercialhaskell/stack/issues/4535)/ + [#4535](https://github.com/commercialhaskell/stack/issues/4535) Bug fixes: @@ -25,6 +25,8 @@ Bug fixes: - Help text for the `templates` subcommand now reflects behaviour in stack 1.9 — that it downloads and shows a help file, rather than listing available templates. - Fix detection of aarch64 platform (this broke when we upgraded to a newer Cabal version). +- Docker: fix detecting and pulling missing images with `--docker-auto-pull`, see + [#4598](https://github.com/commercialhaskell/stack/issues/4598) ## v1.9.3 diff --git a/src/Stack/Docker.hs b/src/Stack/Docker.hs index d660199839..b8b3ddc816 100644 --- a/src/Stack/Docker.hs +++ b/src/Stack/Docker.hs @@ -639,7 +639,8 @@ inspects :: (HasProcessContext env, HasLogFunc env) => [String] -> RIO env (Map String Inspect) inspects [] = return Map.empty inspects images = - do maybeInspectOut <- try (readDockerProcess ("inspect" : images)) + do maybeInspectOut <- + try (BL.toStrict . fst <$> proc "docker" ("inspect" : images) readProcess_) case maybeInspectOut of Right inspectOut -> -- filtering with 'isAscii' to workaround @docker inspect@ output containing invalid UTF-8 From 13de29e3eadfb292356845db961502839663091f Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Thu, 7 Mar 2019 16:17:37 +0200 Subject: [PATCH 2/3] Fix hlint warnings --- src/Stack/Build/ConstructPlan.hs | 4 ++-- src/Stack/Build/Source.hs | 2 +- src/Stack/Types/Compiler.hs | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Stack/Build/ConstructPlan.hs b/src/Stack/Build/ConstructPlan.hs index 864fc92497..155c10b3cf 100644 --- a/src/Stack/Build/ConstructPlan.hs +++ b/src/Stack/Build/ConstructPlan.hs @@ -230,8 +230,8 @@ constructPlan ls0 baseConfigOpts0 locals extraToBuild0 localDumpPkgs loadPackage throwM $ ConstructPlanFailed "Plan construction failed." where hasBaseInDeps bconfig = - elem $(mkPackageName "base") - $ map (packageIdentifierName . pirIdent) [i | (PLIndex i) <- bcDependencies bconfig] + $(mkPackageName "base") `elem` + [packageIdentifierName (pirIdent i) | (PLIndex i) <- bcDependencies bconfig] mkCtx econfig = Ctx { ls = ls0 diff --git a/src/Stack/Build/Source.hs b/src/Stack/Build/Source.hs index b4c5777ba1..4dfae000c6 100644 --- a/src/Stack/Build/Source.hs +++ b/src/Stack/Build/Source.hs @@ -328,7 +328,7 @@ checkFlagsUsed boptsCli lps extraDeps snapshot = do -- Check if flags specified in stack.yaml and the command line are -- used, see https://github.com/commercialhaskell/stack/issues/617 - let flags = map (, FSCommandLine) [(k, v) | (Just k, v) <- Map.toList $ boptsCLIFlags boptsCli] + let flags = [((k, v), FSCommandLine) | (Just k, v) <- Map.toList $ boptsCLIFlags boptsCli] ++ map (, FSStackYaml) (Map.toList $ bcFlags bconfig) localNameMap = Map.fromList $ map (packageName . lpPackage &&& lpPackage) lps diff --git a/src/Stack/Types/Compiler.hs b/src/Stack/Types/Compiler.hs index f6f9e545de..5c54bfa5db 100644 --- a/src/Stack/Types/Compiler.hs +++ b/src/Stack/Types/Compiler.hs @@ -4,7 +4,6 @@ {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE KindSignatures #-} {-# LANGUAGE TypeFamilies #-} module Stack.Types.Compiler where From 6e224f518b70317c2e9abaa8cc2c1f6597636228 Mon Sep 17 00:00:00 2001 From: David Baynard Date: Sat, 9 Mar 2019 18:11:26 +0000 Subject: [PATCH 3/3] Document the way readDockerProcess passes stderr unchanged --- src/Stack/Docker.hs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Stack/Docker.hs b/src/Stack/Docker.hs index b8b3ddc816..f65610870a 100644 --- a/src/Stack/Docker.hs +++ b/src/Stack/Docker.hs @@ -640,6 +640,8 @@ inspects :: (HasProcessContext env, HasLogFunc env) inspects [] = return Map.empty inspects images = do maybeInspectOut <- + -- not using 'readDockerProcess' as the error from a missing image + -- needs to be recovered. try (BL.toStrict . fst <$> proc "docker" ("inspect" : images) readProcess_) case maybeInspectOut of Right inspectOut -> @@ -844,11 +846,16 @@ removeDirectoryContents path excludeDirs excludeFiles = -- | Produce a strict 'S.ByteString' from the stdout of a -- process. Throws a 'ReadProcessException' exception if the --- process fails. Logs process's stderr using @logError@. +-- process fails. +-- +-- The stderr output is passed straight through, which is desirable for some cases +-- e.g. docker pull, in which docker uses stderr for progress output. +-- +-- Use 'readProcess_' directly to customize this. readDockerProcess :: (HasProcessContext env, HasLogFunc env) => [String] -> RIO env BS.ByteString -readDockerProcess args = BL.toStrict <$> proc "docker" args readProcessStdout_ -- FIXME stderr isn't logged with logError, should it be? +readDockerProcess args = BL.toStrict <$> proc "docker" args readProcessStdout_ -- | Name of home directory within docker sandbox. homeDirName :: Path Rel Dir