Skip to content

Commit

Permalink
Canonicalize CARGO_MANIFEST_DIR in case it's set as a relpath and cau…
Browse files Browse the repository at this point in the history
…ses crashes FileAssetIo's strip_prefix.
  • Loading branch information
golddranks committed Aug 15, 2022
1 parent f1be89d commit b1a786b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion crates/bevy_asset/src/io/file_asset_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,14 @@ impl FileAssetIo {
/// instead. It's set by cargo when running with `cargo run`.
pub fn get_base_path() -> PathBuf {
if let Ok(manifest_dir) = env::var("CARGO_MANIFEST_DIR") {
PathBuf::from(manifest_dir)
// Some Windows software don't support canonicalized path names, so let's avoid them
// unless the path is relative, in which case we currently need to make it absolute
// (See more: https://github.com/rust-lang/rust/issues/59117 )
if Path::new(&manifest_dir).is_relative() {
fs::canonicalize(&manifest_dir).unwrap_or_else(|_| PathBuf::from(manifest_dir))
} else {
PathBuf::from(manifest_dir)
}
} else {
env::current_exe()
.map(|path| {
Expand Down

0 comments on commit b1a786b

Please sign in to comment.