Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cabal run should send info logging to stderr not stdout #7790

Open
gbaz opened this issue Nov 1, 2021 · 5 comments · May be fixed by #7838
Open

cabal run should send info logging to stderr not stdout #7790

gbaz opened this issue Nov 1, 2021 · 5 comments · May be fixed by #7838

Comments

@gbaz
Copy link
Collaborator

gbaz commented Nov 1, 2021

cabal run prints stuff like "up to date" to stdout. So running an executable and cabal run an executable give different output to stdout, which is no good when the executable is producing output for e.g. machine consumption. We should do our info logging to stderr.

@fgaz
Copy link
Member

fgaz commented Nov 2, 2021

Related/duplicates: #5595 #4652 #4789

@jneira
Copy link
Member

jneira commented Nov 2, 2021

Not sure about that, maybe there are programs expecting the actual behaviour, i.e. both cabal and the progam output in stdout.
What about separate both outputs in a standard way (using -?), including a comment

See comment in #4789: #4789

@andreasabel
Copy link
Member

See comment in #4789: #4789

@jneira, something went wrong; this does not link to a comment, only to the PR.

@jneira
Copy link
Member

jneira commented Dec 30, 2022

tbh i cant determine what is the relevant comment right now 😅

@pacien
Copy link

pacien commented May 9, 2023

Note that Cabal already prints some of its warnings on stderr.
This is also the case for GHC warnings.

As a result, we get logs split between both stderr and stdout,
before the output of the target executable that is being run.

The output is someting like this (prefixes and blank lines added):

> cabal run print-csv

STDERR: Warning: The package list for 'hackage.haskell.org' does not exist.
STDERR: Run 'cabal update' to download it.

STDOUT: Resolving dependencies...
STDOUT: Build profile: -w ghc-9.0.2 -O1
STDOUT: [...]

STDERR:
STDERR: lib/[...[:19:1: warning: [-Worphans]
STDERR:    Orphan instance: instance CSV.ToField URI
STDERR:   |
STDERR:23 | instance CSV.ToField URI where
STDERR:   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...

STDOUT: Linking [...] ...

STDOUT: [CSV/JSON/stuff I would actually like to capture or redirect]

jneira:

Not sure about that, maybe there are programs expecting the actual behaviour,
i.e. both cabal and the progam output in stdout.

Given that there is no way of separating the output of Cabal, GHC and the
target executable, currently happening on both stderr and stdout, I doubt that
anyone is making use of the current behaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants