rustlldbbevybevy-v0.13.0

Bevy loading assets relative to debug binary instead of project root


I'm getting the following error when loading a GLTF model:

ERROR bevy_asset::server: Path not found: /path/to/project/target/debug/assets/model.glb

I'm loading the model with

commands.spawn(SceneBundle {
            scene: asset_server.load("model.glb#Scene0"),
            ..default()
        },
    });

I don't understand why it's trying to load the asset relative to the target folder rather than the project root. This page says that it should load relative to the root.

On desktop platforms, it treats asset paths as relative to a folder called assets, that must be placed at one of the following locations:

  • Alongside the game's executable file, for distribution
  • In your Cargo project folder, when running your game using cargo during development This is identified by the CARGO_MANIFEST_DIR environment variable

Solution

  • If you're launching your project for debug with LLDB in VSCode, add the following to your launch config. It will ensure that the "root" of the project is set correctly when debugging.

    "env": {
        "CARGO_MANIFEST_DIR": "${workspaceFolder}"
    },