bevyengine / bevyengine/bevy

Filesystem watching crashes with symlinks pointing outside the asset folder

Open
#5,689 6 comments 0 reactions 0 assignees View on GitHub
A-Assets I-Crash
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## Bevy version

0.8.0

## What you did

I have a symlink pointing to a directory containing some assets, that was located outside of Bevy's assets directory.

## What went wrong

As I modify a file in this directory, Bevy panics here: https://github.com/bevyengine/bevy/blob/main/crates/bevy_asset/src/io/file_asset_io.rs#L191 with `StripPrefixError`.

## Additional information

My attempt to debug this problem showed that (at least on macOS 12.5) the `notify` crate which Bevy uses for filesystem watching, returns an event with asset path `/Users/kon/repos/bomberman-of-the-hill/rounds/1/1.wasm` (the absolute path of the asset, after having followed the symlink) as a response to modifying this asset, whereas `asset_io.root_path` is set to `/Users/kon/repos/bomberman-of-the-hill/crates/bomber_game/assets/`. As you can see from this Playground snippet, this produces a `StripPrefixError`: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=e4662b33f004e4f1a1f7d226a5dbe6c8

An interesting twist is that the asset would be reachable via path `/Users/kon/repos/bomberman-of-the-hill/crates/bomber_game/assets/rounds/1/1.wasm` and Bevy actually finds and uses this path when using the normal loading functions of `AssetServer` instead of filesystem watching. Of course, Bevy doesn't realize that the assets with differing paths are actually the same.

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.