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

Warning: "debug build with assertions" interferes with --numeric-version #8645

Closed
andreasabel opened this issue Dec 29, 2022 · 10 comments · Fixed by #8647
Closed

Warning: "debug build with assertions" interferes with --numeric-version #8645

andreasabel opened this issue Dec 29, 2022 · 10 comments · Fixed by #8647
Assignees
Labels
re: devx Improving the cabal developer experience (internal issue) re: warnings Concerning warnings printed by cabal

Comments

@andreasabel
Copy link
Member

The warning printed by the cabal development version interferes with collecting output, e.g.

CABAL_VERSION=$(cabal --numeric-version)

will usually set CABAL_VERSION to something like 3.8.1.0, but for the development version it is the warning-string followed by the version:

$ echo $CABAL_VERSION
Warning: this is a debug build of cabal-install with assertions enabled. 3.9

The problem is that this warning is printed to stdout with normal verbosity:

warnIfAssertionsAreEnabled :: IO ()
warnIfAssertionsAreEnabled =
assert False (return ()) `catch`
(\(_e :: AssertionFailed) -> warn normal assertionsEnabledMsg)
where
assertionsEnabledMsg =
"this is a debug build of cabal-install with assertions enabled."

I think this warning should only be printed with increased verbosity, e.g. -v2.

What confuses me is that -v0 does not seem to have any effect:

$ cabal -v0 --numeric-version
Warning: this is a debug build of cabal-install with assertions enabled.
3.9

I still see this well-meant but silly warning.

@andreasabel andreasabel added re: devx Improving the cabal developer experience (internal issue) re: warnings Concerning warnings printed by cabal labels Dec 29, 2022
@Mikolaj
Copy link
Member

Mikolaj commented Dec 29, 2022

I suppose normal verbosity is needed to help people avoid surprises. However, -v0 should work, so it's worth investigating. Also, I think there is a ticket about printing warnings (and errors?) to stderr.

@andreasabel
Copy link
Member Author

Also, I think there is a ticket about printing warnings (and errors?) to stderr.

We have:

This topic has a history...

I suppose normal verbosity is needed to help people avoid surprises.

Why do we need this warning preemptively at all? Couldn't we just add it as explanation if an actual assertion is thrown? In >99% of my invocations of cabal, this message is just spamming me.

I'd think the best path of action here (if we want to avoid the thickets of stdout vs stderr) is to remove the warning and only utter it when an assertion failed.

@Mikolaj
Copy link
Member

Mikolaj commented Dec 30, 2022

@andreasabel
Copy link
Member Author

Ok, to not start a revolution, I submitted a modest PR that shifts the warning to stderr and restricts it to normal operation of cabal, i.e. not in special commands such as help and version:

@ulysses4ever
Copy link
Collaborator

I like the idea of printing it only when an assertion actually fails.

@grayjay
Copy link
Collaborator

grayjay commented Jan 4, 2023

I like the idea of printing it only when an assertion actually fails.

I think that the main purpose of the warning is to warn about decreased performance.

@mergify mergify bot closed this as completed in #8647 Jan 5, 2023
mergify bot added a commit that referenced this issue Jan 5, 2023
#8647)

* Fix #8654: no assertion warning on special modes (help, version, etc.)

This patch moves the `warnIfAssertionsAreEnabled` until after the main
command line argument parsing, and then only prints it on regular
operation, i.e. not when just the help or version of cabal was
demanded, or the command line could not be parsed.

Further, the warning is printed on stderr.  The previous attempt to
use `warn` does not work as expected, as the verbosity aperatshnik
isn't in place yet, so the warning cannot be suppressed by -v0.

Drive-by-shooting: straighten the convoluted control flow involving
`maybeScriptAndArgs`.  This IO computation was invoked "brutto"
before, when it is actually only needed in *one* branch of the case
distinction.

* PR #8647: changelog, fix text of warning

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
@andreasabel
Copy link
Member Author

@grayjay wrote:

I think that the main purpose of the warning is to warn about decreased performance.

Digging the history I saw that once this warning had some text about decreased performance. Do you know why this part was dropped?

@andreasabel andreasabel self-assigned this Jan 6, 2023
@gbaz
Copy link
Collaborator

gbaz commented Jan 6, 2023

Just as a historical note, there was certainly a case I found at some point where we were shipping binaries that accidentally had assertions on, leading to vastly decreased solver performance. I think having some warning in at least some cases is a good guard against this.

@grayjay
Copy link
Collaborator

grayjay commented Jan 6, 2023

Digging the history I saw that once this warning had some text about decreased performance. Do you know why this part was dropped?

Which warning mentioned decreased performance? Are you referring to the expensive assertions mentioned in #8240? They were only enabled with a custom build flag, so they were not easy to enable unintentionally.

@andreasabel
Copy link
Member Author

@grayjay: Ah, it was in a PR that didn't get merged as such:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
re: devx Improving the cabal developer experience (internal issue) re: warnings Concerning warnings printed by cabal
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants