NiklasEi / bevy_game_template

Template for a Bevy game including CI/CD for web, Windows, Linux, macOS, iOS and Android
https://niklasei.github.io/bevy_game_template/
Creative Commons Zero v1.0 Universal
847 stars 89 forks source link

Fix asset loading in debug launch config on Linux #72

Closed caspark closed 1 year ago

caspark commented 1 year ago

Problem

When running the Debug launch configuration in vscode on Linux, the assets are not loaded, so the menu button is not visible. The Quick Launch launch configuration works fine.

Diagnosis

  1. Bevy logs show lines like 2023-08-10T11:39:58.234289Z WARN bevy_asset::asset_server: encountered an error while reading an asset: path not found: /home/foo/src/bevy_game/target/debug/assets/fonts/FiraSans-Bold.ttf , indicating that Bevy isn't detecting the root folder correctly.
  2. The Debug launch configuration is setting CARGO_MANIFEST_DIR as (one of the variables that) Bevy expects to see, however cat "/proc/$(pgrep bevy_game)/environ" | tr '\0' '\n' | grep CARGO returns no results, indicating that the environment variable isn't actually getting set.
  3. Vscode docs say Properties defined in an operating system specific scope override properties defined in the global scope. so the .linux.env setting is overriding the .env setting (rather than being merged with it, as one might reasonably expect).

Fix

Duplicate CARGO_MANIFEST_DIR into .linux.env.

Other notes

NiklasEi commented 1 year ago

I do not use vscode. The setup was contributed in #9.

@TheRawMeatball any opinion on this?