-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Conversation
There was a problem hiding this 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.
I agree with the wording change though. Being specific about adding it twice doesn’t catch the possibilities in a literal sense.
Does the compiler prevent you from adding it three or more times? I know it does not for adding it twice.
Compiler checks for this would be ideal but that’s outside my knowledge at this moment.
Get Outlook for iOS<https://aka.ms/o0ukef>
________________________________
From: bjorn3 ***@***.***>
Sent: Sunday, October 17, 2021 12:08:38 PM
To: bevyengine/bevy ***@***.***>
Cc: Mirko Rainer ***@***.***>; Author ***@***.***>
Subject: Re: [bevyengine/bevy] Add error that arises from adding DefaultPlugin twice. (#2983)
@bjorn3 commented on this pull request.
________________________________
In crates/bevy_log/src/lib.rs<#2983 (comment)>:
@@ -126,7 +126,7 @@ impl Plugin for LogPlugin {
let subscriber = subscriber.with(tracy_layer);
bevy_utils::tracing::subscriber::set_global_default(subscriber)
- .expect("Could not set global default tracing subscriber. If you've already set up a tracing subscriber, please disable LogPlugin from Bevy's DefaultPlugins");
+ .expect("Could not set global default tracing subscriber. If you've already set up a tracing subscriber, please disable LogPlugin from Bevy's DefaultPlugins. Also, check that you're not accidentally adding DefaultPlugins twice.");
It will immediately panic the second time you add it, so you don't even have the chance to add it a third time.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#2983 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AMTS6CHAQWUDZD4PMYMTII3UHLYINANCNFSM5GEEFCSQ>.
|
And by compiler, I mean a nice red squiggly line in the IDE.
Get Outlook for iOS<https://aka.ms/o0ukef>
________________________________
From: Mirko Rainer ***@***.***>
Sent: Sunday, October 17, 2021 12:42:21 PM
To: bevyengine/bevy ***@***.***>; bevyengine/bevy ***@***.***>
Cc: Author ***@***.***>
Subject: Re: [bevyengine/bevy] Add error that arises from adding DefaultPlugin twice. (#2983)
I agree with the wording change though. Being specific about adding it twice doesn’t catch the possibilities in a literal sense.
Does the compiler prevent you from adding it three or more times? I know it does not for adding it twice.
Compiler checks for this would be ideal but that’s outside my knowledge at this moment.
Get Outlook for iOS<https://aka.ms/o0ukef>
________________________________
From: bjorn3 ***@***.***>
Sent: Sunday, October 17, 2021 12:08:38 PM
To: bevyengine/bevy ***@***.***>
Cc: Mirko Rainer ***@***.***>; Author ***@***.***>
Subject: Re: [bevyengine/bevy] Add error that arises from adding DefaultPlugin twice. (#2983)
@bjorn3 commented on this pull request.
________________________________
In crates/bevy_log/src/lib.rs<#2983 (comment)>:
@@ -126,7 +126,7 @@ impl Plugin for LogPlugin {
let subscriber = subscriber.with(tracy_layer);
bevy_utils::tracing::subscriber::set_global_default(subscriber)
- .expect("Could not set global default tracing subscriber. If you've already set up a tracing subscriber, please disable LogPlugin from Bevy's DefaultPlugins");
+ .expect("Could not set global default tracing subscriber. If you've already set up a tracing subscriber, please disable LogPlugin from Bevy's DefaultPlugins. Also, check that you're not accidentally adding DefaultPlugins twice.");
It will immediately panic the second time you add it, so you don't even have the chance to add it a third time.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#2983 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AMTS6CHAQWUDZD4PMYMTII3UHLYINANCNFSM5GEEFCSQ>.
|
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.
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 |
Closing in favor of the more general #2988. |
Objective
I was copy and pasting some code between projects and accidentally had
.add_plugins(DefaultPlugins)
twice. This resulted inthread '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.