Add error that arises from adding DefaultPlugin twice.#2983
Closed
mirkoRainer wants to merge 3 commits intobevyengine:mainfrom
Closed
Add error that arises from adding DefaultPlugin twice.#2983mirkoRainer wants to merge 3 commits intobevyengine:mainfrom
mirkoRainer wants to merge 3 commits intobevyengine:mainfrom
Conversation
alice-i-cecile
approved these changes
Oct 16, 2021
Member
alice-i-cecile
left a comment
There was a problem hiding this comment.
Nice :) That should be a more helpful error message in a large fraction of the places that this shows up.
Weibye
reviewed
Oct 17, 2021
Contributor
Author
|
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>.
|
Contributor
Author
|
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>.
|
Contributor
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.
alice-i-cecile
approved these changes
Oct 17, 2021
Weibye
approved these changes
Oct 18, 2021
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 |
Member
Member
|
Closing in favor of the more general #2988. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.