-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
embedded_asset!
panics on unwrap
during path manipulation
#10377
Comments
bonsairobo
added
C-Bug
An unexpected or incorrect behavior
S-Needs-Triage
This issue needs to be labelled
labels
Nov 5, 2023
I also find that. A pr about that is open #10379 by me. |
It's such a annoying problem. I spent the whole morning trying to find the source. : ( |
alice-i-cecile
added
A-Assets
Load files from disk to use for things like images, models, and sounds
and removed
S-Needs-Triage
This issue needs to be labelled
labels
Nov 8, 2023
An example, temporary solution if you have problems with linux/windows compilation: #[cfg(any(not(target_family = "windows"), target_env = "gnu"))]
{
embedded_asset!(app, "src/", "fonts/Ubuntu-Light.ttf");
}
#[cfg(all(target_family = "windows", not(target_env = "gnu")))]
{
embedded_asset!(app, "src\\", "fonts\\Ubuntu-Light.ttf");
} |
ria8651
added a commit
to ria8651/bevy-voxel-engine
that referenced
this issue
Feb 1, 2024
github-merge-queue bot
pushed a commit
that referenced
this issue
Feb 2, 2024
# Objective Fixes #10377 ## Solution Use `Path::strip_prefix` instead of `str::split`. Avoid any explicit "/" characters in path manipulation. --- ## Changelog - Added: example of embedded asset loading - Added: support embedded assets in external crates - Fixed: resolution of embedded assets - Fixed: unexpected runtime panic during asset path resolution ## Migration Guide No API changes. --------- Co-authored-by: Shane Celis <shane.celis@gmail.com>
tjamaan
pushed a commit
to tjamaan/bevy
that referenced
this issue
Feb 6, 2024
# Objective Fixes bevyengine#10377 ## Solution Use `Path::strip_prefix` instead of `str::split`. Avoid any explicit "/" characters in path manipulation. --- ## Changelog - Added: example of embedded asset loading - Added: support embedded assets in external crates - Fixed: resolution of embedded assets - Fixed: unexpected runtime panic during asset path resolution ## Migration Guide No API changes. --------- Co-authored-by: Shane Celis <shane.celis@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bevy version
0.12.0
What you did
What went wrong
Additional information
Root Cause
I believe the root cause it trying to split a path string by "/src/" when the path does not even contain that substring.
Here's the implementation:
This line is where the panic happens:
The issue is
$source_path = "/src/"
whilefile!() = "src/plugin.rs"
. Splitting will produce only one element from the iterator, sonth(1)
will beNone
.Solution
Generally it's a bad idea to do path manipulation with raw strings when you could use
Path
orPathBuf
instead, and I recommend eliminating any use of "/" (it's not portable), e.g. in"/src/"
. So my suggested solution is to convert strings intoPathBuf
as soon as possible and do manipulation after that.The text was updated successfully, but these errors were encountered: