bevyengine / bevyengine/bevy

Panic on Loading Asset from Absolute Path

Open
#11,271 2 comments 0 reactions 0 assignees View on GitHub
A-Assets C-Bug
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## Bevy version

0.12.1
Also tested on commit hash: https://github.com/bevyengine/bevy/commit/41c362051cbfc57ecbaca57b8546a5695717b727

## Relevant system information

Dell Precision 7670
Windows 11 Enterprise (10.0.22621 Build 22621)

## What you did

I've been trying to load assets from absolute file paths (I'm making a small GLTF viewer which does not come pre-packaged with its models). Loading with asset_server.load() (where asset_server is Res) worked okay in Bevy 0.11 but in 0.12 I hit problems.

For example:

```
commands.spawn((
SceneBundle {
// scene: asset_server.load(r"C:\Users\user\my-proj\assets\models\model.glb#Scene0"), // throws error
scene: asset_server.load(r"models\model.glb#Scene0"), // works!
..default()
},
ModelInstance {},
));
```

I also tested this against absolute paths provided from drag-and-drop events.

## What went wrong

I expected the two load() lines above to be equivalent, but if I use the one with the absolute path I get the following error and my application panics:
```
thread 'Compute Task Pool (15)' panicked at C:\Users\koceom0\.cargo\registry\src\index.crates.io-6f17d22bba15001f\bevy_asset-0.12.0\src\path.rs:458:70:
called `Result::unwrap()` on an `Err` value: InvalidSourceSyntax
```

I don't see anything about this specifically in the migration guide, so I'm assuming this is not expected behaviour.

## Additional information

I was able to work around this issue by using the pathdiff crate to convert the absolute path into one which is relative to the current working directory. With this work-around it seems I'm able to load assets from anywhere on the system, confirming for me that issue above is not an access one.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.