Skip to content

Add error that arises from adding DefaultPlugin twice. #2983

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

Closed
wants to merge 3 commits into from

Conversation

mirkoRainer
Copy link
Contributor

@mirkoRainer mirkoRainer commented Oct 16, 2021

Objective

I was copy and pasting some code between projects and accidentally had .add_plugins(DefaultPlugins) twice. This resulted in thread 'main' panicked at 'Could not set global default tracing subscriber. If you've already set up a tracing subscriber, please disable LogPlugin from Bevy's DefaultPlugins: SetGlobalDefaultError { _no_construct: () }', /Users/mirkorainer/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_log-0.5.0/src/lib.rs:85:22 note: run with 'RUST_BACKTRACE=1' environment variable to display a backtrace.

I understand this error to a degree, but I imagine importing Defaults could be a common mistake for beginners or people cobbling together examples found on blogs, etc. so wanted to add to the error message.

Solution

Added an extra sentence to the error message.

@github-actions github-actions bot added the S-Needs-Triage This issue needs to be labelled label Oct 16, 2021
@alice-i-cecile alice-i-cecile added A-App Bevy apps and plugins C-Usability A targeted quality-of-life change that makes Bevy easier to use S-Needs-Review and removed S-Needs-Triage This issue needs to be labelled labels Oct 16, 2021
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice :) That should be a more helpful error message in a large fraction of the places that this shows up.

@mirkoRainer
Copy link
Contributor Author

mirkoRainer commented Oct 17, 2021 via email

@mirkoRainer
Copy link
Contributor Author

mirkoRainer commented Oct 17, 2021 via email

@bjorn3
Copy link
Contributor

bjorn3 commented Oct 17, 2021

Does the compiler prevent you from adding it three or more times? I know it does not for adding it twice.

No, it doesn't.

This error could result when adding the plugins more than once, not only just when you do it twice.
This error could result when adding the plugins more than once, not only just when you do it twice.
@mockersf
Copy link
Member

as part of a change on plugin initialization in #2988, I added a way to block adding the same plugin or the same plugin group twice

@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review labels Oct 24, 2021
@alice-i-cecile
Copy link
Member

This is ready for final review, but only one of #2983 or #2988 should be merged.

@alice-i-cecile
Copy link
Member

Closing in favor of the more general #2988.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-App Bevy apps and plugins C-Usability A targeted quality-of-life change that makes Bevy easier to use S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants