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 path writes purely informational output to stdout instead of stderr #10200

Closed
sol opened this issue Jul 14, 2024 · 1 comment
Closed

cabal path writes purely informational output to stdout instead of stderr #10200

sol opened this issue Jul 14, 2024 · 1 comment

Comments

@sol
Copy link
Member

sol commented Jul 14, 2024

Describe the bug

I think it's a common misconception that stderr is meant for error messages only. A better way to think about whether to write something to stdout or stderr may be:

  1. When a program produces some output and you redirect stdout when running that program then do you in the common case want this output to be captured (== redirected)? If yes, write it to stdout. If no, write it to stderr.
  2. For purely informational output you don't want it to be captured in the common case.
  3. Note that there are special cases where you want to capture all output, including error message. An example would be a CI system, like Jenkins or GitHub actions.

To Reproduce
Steps to reproduce the behavior:

$ rm -f ~/.config/cabal/config
$ cabal path --installdir > result
$ cat result
Config file path source is default config file.
Config file not found: /home/sol/.config/cabal/config
Writing default configuration to /home/sol/.config/cabal/config
/home/sol/.local/bin

Expected behavior

$ rm -f ~/.config/cabal/config
$ cabal path --installdir > result
Config file path source is default config file.
Config file not found: /home/sol/.config/cabal/config
Writing default configuration to /home/sol/.config/cabal/config
$ cat result
/home/sol/.local/bin

System information

$ cabal --version
cabal-install version 3.12.1.0
compiled using version 3.12.1.0 of the Cabal library

Workaround

$ rm -f ~/.config/cabal/config && cabal -v0 path --installdir
@sol sol changed the title Cabal writes purely informational output to stdout instead of stderr cabal path writes purely informational output to stdout instead of stderr Jul 14, 2024
@sol sol changed the title cabal path writes purely informational output to stdout instead of stderr Cabal writes purely informational output to stdout instead of stderr Jul 14, 2024
@sol sol changed the title Cabal writes purely informational output to stdout instead of stderr cabal path writes purely informational output to stdout instead of stderr Jul 14, 2024
@sol sol changed the title cabal path writes purely informational output to stdout instead of stderr Cabal writes purely informational output to stdout instead of stderr Jul 14, 2024
@sol sol changed the title Cabal writes purely informational output to stdout instead of stderr cabal path writes purely informational output to stdout instead of stderr Jul 14, 2024
@sol sol changed the title cabal path writes purely informational output to stdout instead of stderr cabal path writes purely informational output to stdout instead of stderr Jul 14, 2024
@ulysses4ever
Copy link
Collaborator

This is not about cabal path exclusively, so I'd suggest to change back the title of the issue to say "Cabal writes purely...".

This issue has come up several times: #8870, #7790, #4652 #9911

There are two old draft PRs:

There are some design consideration that were not resolved (what should remain on stdout exactly), but they're not that bad: I'd say we could err on the side of sending more to stderr first and then play it by the year (get bug reports and revert part of the output back to stdout).

A bigger technical problem, as funny as it sounds, is adjusting our humongous test suite. I'm still to see a brave soul who would take this on.

I'm tentatively closing this as a duplicate, but feel free to reopen if you disagree.

@ulysses4ever ulysses4ever closed this as not planned Won't fix, can't repro, duplicate, stale Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants