Skip to content

Commit e20f557

Browse files
committed
Merge branch 'master' into rio
2 parents b4dd7ea + 2924632 commit e20f557

14 files changed

Lines changed: 80 additions & 49 deletions

File tree

ChangeLog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ Other enhancements:
3737
* Nix integration is now disabled on windows even if explicitly enabled,
3838
since it isn't supported. See
3939
[#3600](https://github.com/commercialhaskell/stack/issues/3600)
40+
* `stack build` now supports a new flag `--keep-tmp-files` to retain intermediate
41+
files and directories for the purpose of debugging.
42+
It is best used with ghc's equivalent flag,
43+
i.e. `stack build --keep-tmp-files --ghc-options=-keep-tmp-files`.
44+
See [#3857](https://github.com/commercialhaskell/stack/issues/3857)
4045

4146
Bug fixes:
4247
* 1.6.1 introduced a change that made some precompiled cache files use

doc/install_and_upgrade.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,29 +94,32 @@ problems, see the linked FAQ entries:
9494

9595
* [GHC 7.8.4 fails with `/usr/bin/ar: permission denied`](faq.md#usr-bin-ar-permission-denied)
9696
* [DYLD_LIBRARY_PATH is ignored](faq.md#dyld-library-path-ignored)
97-
97+
9898

9999
If you are on OS X 10.12 ("Sierra") and encounter [GHC panic while building, see this issue](https://github.com/commercialhaskell/stack/issues/2577)
100100

101101
## Ubuntu
102102

103103
Use the [generic Linux option](#linux).
104104

105-
There is also
106-
a
107-
[Ubuntu package](http://packages.ubuntu.com/search?keywords=haskell-stack&searchon=names&suite=all&section=all) for
108-
Ubuntu 16.04 and up. Note that the distribution's Stack version lags behind, so
109-
we recommend running `stack upgrade` after installing it.
105+
There is also a [Ubuntu
106+
package](http://packages.ubuntu.com/search?keywords=haskell-stack&searchon=names&suite=all&section=all)
107+
for Ubuntu 16.10 and up, but the distribution's Stack version lags behind, so we
108+
recommend running `stack upgrade --binary` after installing it. For older stack
109+
versions which do not support `--binary`, just `stack upgrade` is fine too. The
110+
version in Ubuntu 16.04 is too old to upgrade successfully, and so in that case
111+
stack should be installed from a [release
112+
tarball](https://github.com/commercialhaskell/stack/releases).
110113

111114
## Debian
112115

113116
Use the [generic Linux option](#linux).
114117

115-
There is also
116-
a
117-
[Debian package](https://packages.debian.org/search?keywords=haskell-stack&searchon=names&suite=all&section=all) for
118-
Stretch and up. Note that the distribution's Stack version lags behind, so
119-
we recommend running `stack upgrade` after installing it.
118+
There is also a [Debian
119+
package](https://packages.debian.org/search?keywords=haskell-stack&searchon=names&suite=all&section=all)
120+
for Stretch and up, but the distribution's Stack version lags behind, so running
121+
`stack upgrade --binary` is recommended after installing it. For older stack
122+
versions which do not support `--binary`, just `stack upgrade` is fine too.
120123

121124
## <a name="centos"></a>CentOS / Red Hat / Amazon Linux
122125

@@ -192,7 +195,7 @@ can also get the `haskell-stack-tool` package from there.
192195

193196
Users who follow the `nixos-unstable` channel or the Nixpkgs `master` branch can install the latest `stack` release into their profile by running:
194197

195-
nix-env -f "<nixpkgs>" -iA haskellPackages.stack
198+
nix-env -f "<nixpkgs>" -iA stack
196199

197200
Alternatively, the package can be built from source as follows.
198201

doc/yaml_configuration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,7 @@ build:
747747
copy-bins: false
748748
prefetch: false
749749
keep-going: false
750+
keep-tmp-files: false
750751
751752
# NOTE: global usage of haddock can cause build failures when documentation is
752753
# incorrectly formatted. This could also affect scripts which use stack.

package.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,11 @@ executables:
268268
stack:
269269
main: Main.hs
270270
source-dirs: src/main
271+
generated-other-modules: Build_stack
271272
ghc-options:
272273
- -threaded
273274
dependencies:
274275
- stack
275-
other-modules:
276-
- Paths_stack
277276
when:
278277
- condition: flag(static)
279278
ld-options:

src/Stack/Build/ConstructPlan.hs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,12 +1052,12 @@ pprintExceptions exceptions stackYaml parentMap wanted =
10521052
align ((if range == Cabal.anyVersion
10531053
then flow "needed"
10541054
else flow "must match" <+> goodRange) <> "," <> softline <>
1055-
flow "but the stack configuration has no specified version" <>
1055+
flow "but the stack configuration has no specified version" <+>
10561056
latestApplicable Nothing)
10571057
-- TODO: For local packages, suggest editing constraints
10581058
DependencyMismatch version -> Just $
10591059
(styleError . display) (PackageIdentifier name version) <+>
1060-
align (flow "from stack configuration does not match" <+> goodRange <>
1060+
align (flow "from stack configuration does not match" <+> goodRange <+>
10611061
latestApplicable (Just version))
10621062
-- I think the main useful info is these explain why missing
10631063
-- packages are needed. Instead lets give the user the shortest
@@ -1070,7 +1070,10 @@ pprintExceptions exceptions stackYaml parentMap wanted =
10701070
goodRange = styleGood (fromString (Cabal.display range))
10711071
latestApplicable mversion =
10721072
case mlatestApplicable of
1073-
Nothing -> ""
1073+
Nothing
1074+
| isNothing mversion ->
1075+
flow "(no package with that name found, perhaps there is a typo in a package's build-depends or an omission from the stack.yaml packages list?)"
1076+
| otherwise -> ""
10741077
Just la
10751078
| mlatestApplicable == mversion -> softline <>
10761079
flow "(latest matching version is specified)"

src/Stack/Build/Execute.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ withExecuteEnv :: forall env a. HasEnvConfig env
319319
-> (ExecuteEnv -> RIO env a)
320320
-> RIO env a
321321
withExecuteEnv bopts boptsCli baseConfigOpts locals globalPackages snapshotPackages localPackages inner =
322-
withSystemTempDir stackProgName $ \tmpdir -> do
322+
createTempDirFunction stackProgName $ \tmpdir -> do
323323
configLock <- liftIO $ newMVar ()
324324
installLock <- liftIO $ newMVar ()
325325
idMap <- liftIO $ newTVarIO Map.empty
@@ -382,6 +382,10 @@ withExecuteEnv bopts boptsCli baseConfigOpts locals globalPackages snapshotPacka
382382
where
383383
toDumpPackagesByGhcPkgId = Map.fromList . map (\dp -> (dpGhcPkgId dp, dp))
384384

385+
createTempDirFunction
386+
| Just True <- boptsKeepTmpFiles bopts = withKeepSystemTempDir
387+
| otherwise = withSystemTempDir
388+
385389
dumpLogs :: TChan (Path Abs Dir, Path Abs File) -> Int -> RIO env ()
386390
dumpLogs chan totalWanted = do
387391
allLogs <- fmap reverse $ liftIO $ atomically drainChan

src/Stack/Config/Build.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ buildOptsFromMonoid BuildOptsMonoid{..} = BuildOpts
5050
(boptsPreFetch defaultBuildOpts)
5151
buildMonoidPreFetch
5252
, boptsKeepGoing = getFirst buildMonoidKeepGoing
53+
, boptsKeepTmpFiles = getFirst buildMonoidKeepTmpFiles
5354
, boptsForceDirty = fromFirst
5455
(boptsForceDirty defaultBuildOpts)
5556
buildMonoidForceDirty

src/Stack/Ghci.hs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -746,17 +746,19 @@ targetWarnings stackYaml localTargets nonLocalTargets mfileTargets = do
746746
, flow "It can still be useful to specify these, as they will be passed to ghci via -package flags."
747747
]
748748
when (null localTargets && isNothing mfileTargets) $
749-
prettyWarn $ vsep
750-
[ flow "No local targets specified, so ghci will not use any options from your package.yaml / *.cabal files."
749+
prettyNote $ vsep
750+
[ flow "No local targets specified, so a plain ghci will be started with no package hiding or package options."
751+
, ""
752+
, flow "If you want to use package hiding and options, then you can try one of the following:"
751753
, ""
752-
, flow "Potential ways to resolve this:"
753754
, bulletedList
754755
[ fillSep
755-
[ flow "If you want to use the package.yaml / *.cabal package in the current directory, use"
756+
[ flow "If you want to start a different project configuration than" <+> display stackYaml <> ", then you can use"
756757
, styleShell "stack init"
757-
, flow "to create a new stack.yaml."
758+
, flow "to create a new stack.yaml for the packages in the current directory."
759+
, line
758760
]
759-
, flow "Add to the 'packages' field of" <+> display stackYaml
761+
, flow "If you want to use the project configuration at" <+> display stackYaml <> ", then you can add to its 'packages' field."
760762
]
761763
, ""
762764
]

src/Stack/Options/BuildMonoidParser.hs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ buildOptsMonoidParser hide0 =
1919
exeStripping <*> haddock <*> haddockOptsParser hideBool <*>
2020
openHaddocks <*> haddockDeps <*> haddockInternal <*>
2121
haddockHyperlinkSource <*> copyBins <*> copyCompilerTool <*>
22-
preFetch <*> keepGoing <*> forceDirty <*>
22+
preFetch <*> keepGoing <*> keepTmpFiles <*> forceDirty <*>
2323
tests <*> testOptsParser hideBool <*> benches <*>
2424
benchOptsParser hideBool <*> reconfigure <*> cabalVerbose <*> splitObjs <*> skipComponents
2525
where
@@ -120,6 +120,11 @@ buildOptsMonoidParser hide0 =
120120
"keep-going"
121121
"continue running after a step fails (default: false for build, true for test/bench)"
122122
hide
123+
keepTmpFiles =
124+
firstBoolFlags
125+
"keep-tmp-files"
126+
"keep intermediate files and build directories (default: false)"
127+
hide
123128
preFetch =
124129
firstBoolFlags
125130
"prefetch"

src/Stack/Prelude.hs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module Stack.Prelude
66
, withSinkFile
77
, withSinkFileCautious
88
, withSystemTempDir
9+
, withKeepSystemTempDir
910
, sinkProcessStderrStdout
1011
, sinkProcessStdout
1112
, logProcessStderrStdout
@@ -66,6 +67,13 @@ withSinkFileCautious fp inner =
6667
withSystemTempDir :: MonadUnliftIO m => String -> (Path Abs Dir -> m a) -> m a
6768
withSystemTempDir str inner = withRunInIO $ \run -> Path.IO.withSystemTempDir str $ run . inner
6869

70+
-- | Like `withSystemTempDir`, but the temporary directory is not deleted.
71+
withKeepSystemTempDir :: MonadUnliftIO m => String -> (Path Abs Dir -> m a) -> m a
72+
withKeepSystemTempDir str inner = withRunInIO $ \run -> do
73+
path <- Path.IO.getTempDir
74+
dir <- Path.IO.createTempDir path str
75+
run $ inner dir
76+
6977
-- | Consume the stdout and stderr of a process feeding strict 'ByteString's to the consumers.
7078
--
7179
-- Throws a 'ReadProcessException' if unsuccessful in launching, or 'ProcessExitedUnsuccessfully' if the process itself fails.

0 commit comments

Comments
 (0)