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

embedded_watcher does not work in multi-crate workspaces #10575

Open
SludgePhD opened this issue Nov 15, 2023 · 9 comments
Open

embedded_watcher does not work in multi-crate workspaces #10575

SludgePhD opened this issue Nov 15, 2023 · 9 comments
Labels
A-Assets Load files from disk to use for things like images, models, and sounds C-Bug An unexpected or incorrect behavior

Comments

@SludgePhD
Copy link
Contributor

Bevy version

0.12

What you did

Enable the embedded_watcher feature and use embedded_asset! in a subcrate.

What went wrong

The embedded watcher does not react to changes to the embedded file.

Additional information

This is caused by the file watcher watching only the "base path" for changes (by default, this is the runtime value of CARGO_MANIFEST_DIR, which is the path containing the Cargo.toml of the final binary):

let root = get_base_path();
let handler = EmbeddedEventHandler {
dir,
root: root.clone(),
sender,
root_paths,
last_event: None,
};
let watcher = new_asset_event_debouncer(root, debounce_wait_time, handler).unwrap();

It should either be watching every single embedded file path separately, or merge them together by crate (though watching many separate paths may be bad for performance).

@SludgePhD SludgePhD added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Nov 15, 2023
@nicopap nicopap 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 16, 2023
@garyttierney
Copy link

As a temporary workaround I've been able to do:

BEVY_ASSET_ROOT=`pwd` cargo run --package sub_crate

From the workspace root.

@nicopap
Copy link
Contributor

nicopap commented Feb 20, 2024

Testing this today, embedded_assets! at least works with bevy itself, meaning that it should work with arbitrary multi-crate workspaces now. I'm closing this. But do not hesitate re-opening the issue if I'm mistaken.

@nicopap nicopap closed this as completed Feb 20, 2024
@SludgePhD
Copy link
Contributor Author

What fixed it? I'll retest when I find the time.

@nicopap
Copy link
Contributor

nicopap commented Feb 24, 2024

Dunno, looking the blame, I don't see anything specifically addressing this issue, the relevant ones are:

@SludgePhD
Copy link
Contributor Author

Nope, still doesn't seem to work for me on bevy 0.13.

Or to be precise, embedded_asset! does work, but the embedded_watcher does not react to any changes to the embedded file.

@nicopap
Copy link
Contributor

nicopap commented Feb 26, 2024

Ooops, I'm re-opening then.

@nicopap nicopap reopened this Feb 26, 2024
@SludgePhD
Copy link
Contributor Author

It's possible that this only reproduces with virtual workspaces, where the outermost Cargo.toml lacks a [package] section. Bevy doesn't do that, so it might work fine there.

@SK83RJOSH
Copy link

SK83RJOSH commented May 1, 2024

I ran into this today as I started moving some of my rendering plugins to their own crates and realized shader reloading stopped working. I can confirm that it only affects virtual workspaces, and I fixed it on my end by moving my app to be the root crate.

Would be nice to not need to do this though, as down the line I would like to be able to do shader dev while working on examples and so on as well...

@SK83RJOSH
Copy link

SK83RJOSH commented May 2, 2024

Just to follow up on this, I can confirm this happens under the following circumstances:

  • Your project is a virtual workspace
  • Your embedded assets are in a directory outside of the CARGO_MANIFEST_DIR for your app

The only workaround is to set BEVY_ASSETS_ROOT to be the root of your cargo workspace. This of course, means your assets need to live outside of your app crate. Not ideal, but I can work with this for my project, and embed most of my assets into the app and it's crates.

It is unfortunately very unlikely that we will ever have CARGO_WORKSPACE_DIR, so I'm not really sure how you could fix this. Just about the only solution I can see working, would be patching up the embedded_watcher to use a new environment variable, such as BEVY_EMBEDDED_ASSET_ROOT.

Which would require patches here, here and here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Assets Load files from disk to use for things like images, models, and sounds C-Bug An unexpected or incorrect behavior
Projects
None yet
Development

No branches or pull requests

4 participants