commercialhaskell / commercialhaskell/stack

`--dump-logs` not dumping as project builds

Open
#5,853 7 comments 0 reactions 0 assignees View on GitHub
type: enhancement
Dominant language
Haskell
Stars
4.1k
Forks
850
Avg merge
10h 37m
Merged PRs (30d)
4

Description

### General summary/comments

`stack build --dump-logs` dumps logs only after targets are built, while I expect the log to be generated as the target is building (as if using `stack build` to build a single target).

A bit of context on why I want this behavior: I look at logs to get a sense of how long it takes for each module to build, so dumping logs *after* everything is built is not very useful.

### Steps to reproduce

I set up https://github.com/Javran/stack-dump-logs for reproduction.

```
$ stack --version
Version 2.7.5, Git revision ba147e6f59b2da75b1beb98b1888cce97f7032b1 x86_64 hpack-0.34.4
$ cd /tmp; git clone https://github.com/Javran/stack-dump-logs.git; cd stack-dump-logs
```

Compare when I build a single target:
```
$ stack clean && stack build pkg0:lib
Building all executables for `pkg0' once. After a successful build of all of them, only specified executables will be rebuilt.
pkg0> configure (lib + exe)
Configuring pkg0-0.1.0.0...
pkg0> build (lib + exe)
Preprocessing library for pkg0-0.1.0.0..
Building library for pkg0-0.1.0.0..
[1 of 2] Compiling Lib
[2 of 2] Compiling Paths_pkg0
Preprocessing executable 'demo' for pkg0-0.1.0.0..
Building executable 'demo' for pkg0-0.1.0.0..
[1 of 2] Compiling Main
[2 of 2] Compiling Paths_pkg0
Linking .stack-work/dist/x86_64-linux-tinfo6/Cabal-3.4.1.0/build/demo/demo ...
pkg0> copy/register
Installing library in /tmp/stack-dump-logs/.stack-work/install/x86_64-linux-tinfo6/f3024450010dffb8f05b5a95c06ef3329770527d9aa31039b58c30b77ace40a8/9.0.2/lib/x86_64-linux-ghc-9.0.2/pkg0-0.1.0.0-IeQebfee5Cw7c0AcMZdHYq
Installing executable demo in /tmp/stack-dump-logs/.stack-work/install/x86_64-linux-tinfo6/f3024450010dffb8f05b5a95c06ef3329770527d9aa31039b58c30b77ace40a8/9.0.2/bin
Registering library for pkg0-0.1.0.0..
```
To building multiple targets with `--dump-logs`:

```
$ stack clean && stack build --dump-logs
Building several executables with the same name: 'pkg0:demo', 'pkg1:demo'.
Only one of them will be available via 'stack exec' or locally installed.

pkg0-0.1.0.0: unregistering (components added: exe:demo)
Building all executables for `pkg0' once. After a successful build of all of them, only specified executables will be rebuilt.
Building all executables for `pkg1' once. After a successful build of all of them, only specified executables will be rebuilt.
pkg0> configure (lib + exe)
pkg1> configure (lib + exe)
pkg0> build (lib + exe)
pkg1> build (lib + exe)
pkg0> copy/register
pkg1> copy/register
Completed 2 action(s).

-- Dumping log file: /tmp/stack-dump-logs/.stack-work/logs/pkg1-0.1.0.0.log

Configuring pkg1-0.1.0.0...
Preprocessing library for pkg1-0.1.0.0..
Building library for pkg1-0.1.0.0..
[1 of 2] Compiling Lib
[2 of 2] Compiling Paths_pkg1
Preprocessing executable 'demo' for pkg1-0.1.0.0..
Building executable 'demo' for pkg1-0.1.0.0..
[1 of 2] Compiling Main
[2 of 2] Compiling Paths_pkg1
Linking .stack-work/dist/x86_64-linux-tinfo6/Cabal-3.4.1.0/build/demo/demo ...
Installing library in /tmp/stack-dump-logs/.stack-work/install/x86_64-linux-tinfo6/f3024450010dffb8f05b5a95c06ef3329770527d9aa31039b58c30b77ace40a8/9.0.2/lib/x86_64-linux-ghc-9.0.2/pkg1-0.1.0.0-3TDT85szijJLEAQiWjh0ce
Installing executable demo in /tmp/stack-dump-logs/.stack-work/install/x86_64-linux-tinfo6/f3024450010dffb8f05b5a95c06ef3329770527d9aa31039b58c30b77ace40a8/9.0.2/bin
Registering library for pkg1-0.1.0.0..

-- End of log file: /tmp/stack-dump-logs/.stack-work/logs/pkg1-0.1.0.0.log

-- Dumping log file: /tmp/stack-dump-logs/.stack-work/logs/pkg0-0.1.0.0.log

Configuring pkg0-0.1.0.0...
Preprocessing library for pkg0-0.1.0.0..
Building library for pkg0-0.1.0.0..
[1 of 2] Compiling Lib
[2 of 2] Compiling Paths_pkg0
Preprocessing executable 'demo' for pkg0-0.1.0.0..
Building executable 'demo' for pkg0-0.1.0.0..
[1 of 2] Compiling Main
[2 of 2] Compiling Paths_pkg0
Linking .stack-work/dist/x86_64-linux-tinfo6/Cabal-3.4.1.0/build/demo/demo ...
Installing library in /tmp/stack-dump-logs/.stack-work/install/x86_64-linux-tinfo6/f3024450010dffb8f05b5a95c06ef3329770527d9aa31039b58c30b77ace40a8/9.0.2/lib/x86_64-linux-ghc-9.0.2/pkg0-0.1.0.0-IeQebfee5Cw7c0AcMZdHYq
Installing executable demo in /tmp/stack-dump-logs/.stack-work/install/x86_64-linux-tinfo6/f3024450010dffb8f05b5a95c06ef3329770527d9aa31039b58c30b77ace40a8/9.0.2/bin
Registering library for pkg0-0.1.0.0..

-- End of log file: /tmp/stack-dump-logs/.stack-work/logs/pkg0-0.1.0.0.log

Log files have been written to: /tmp/stack-dump-logs/.stack-work/logs/
```

The only flag in `~/.stack/config.yaml` that could be related:

```yaml
build:
interleaved-output: false
```

### Expected & Actual

I expected `stack build --dump-logs` to emit logs as if I'm building targets one at a time. Or to be more precise, I want to see logs about what module it is currently compiling as it builds, not after when it's all done.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.