Skip to content
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

file_watcher feature cannot find assets folder in workspace #16879

Open
super-saturn opened this issue Dec 18, 2024 · 0 comments
Open

file_watcher feature cannot find assets folder in workspace #16879

super-saturn opened this issue Dec 18, 2024 · 0 comments
Labels
C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled

Comments

@super-saturn
Copy link

Bevy version

v0.15.0 #3f2baf8ec

[Optional] Relevant system information

Observed on both Arch Linux and macOS.

What you did

A basic workspace setup where the actual bevy App launches from a subcrate, like the following Cargo.toml setup:

[workspace]
resolver = "2"
members = [
    "library_a",
    "main_bevy_game",
]

The assets folder for the game resides in the main_bevy_game root. There are no other assets folders in the workspace.
main_bevy_game enables file_watcher feature, and then in main.rs:

    App::new()
        .add_plugins(DefaultPlugins.set(AssetPlugin {
            watch_for_changes_override: Some(true),
            ..Default::default()
        }));

What went wrong

On launch, bevy issues the following warning:

WARN bevy_asset::io::source: Skip creating file watcher because path "assets" does not exist.

Creating a folder at the root of the workspace will suppress this warning, but file changes are not recognized.

Moving the assets folder to the root of the workspace causes a panic:

Failed to create file watcher from path "assets", Error { kind: PathNotFound, paths: ["/Users/notarealuser/workspace/main_bevy_game/assets"] }

(Path altered for privacy)

Additional information

I believe this is from using a raw std::path::PathBuf to test if the assets folder exists whereas in most other cases it gets built out.
I have a quick one-line fix:

bevy_asset crate @ bevy_assets/src/io/source.rs

line 534:
let path = super::file::get_base_path().join(path.clone());

This builds the path as it does in file::FileWatcher::new() and seems to make everything work as expected.

This might not be the appropriate fix, or perhaps my project structure is not as intended. I'm not sure, so I haven't opened a PR for this one line change.

@super-saturn super-saturn added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled
Projects
None yet
Development

No branches or pull requests

1 participant