-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Canonicalize CARGO_MANIFEST_DIR #5702
Canonicalize CARGO_MANIFEST_DIR #5702
Conversation
c615d97
to
bf5b49d
Compare
|
Thanks for pointing that out! In that case it makes sense to revert to the original path in case of a failure. |
a5c1a20
to
e3e0afe
Compare
Will this also fix #5689? |
@alice-i-cecile Unfortunately, it doesn't. However, I'm planning to play around with |
…ses crashes FileAssetIo's strip_prefix.
e3e0afe
to
b1a786b
Compare
Hmm, I think I failed to understand what @bjorn3 meant; according to rust-lang/rust#59117 , canonicalized path names on Windows may cause problems even in cases the canonicalization itself succeeds. This made me to change the implementation once more: it now performs the canonicalization only if the path is relative. ( |
Once rust-lang/rust#92750 stabilizes, this should use it instead? (If relative paths are still unsupported by |
// 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() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think overloading CARGO_MANIFEST_DIR
with the responsibility of "configuring deployed app asset folder root relative paths" is the right path forward, especially if it is consistently an absolute path within the context of cargo. At the very least, we should have a new environment variable for this scenario.
However, I don't think we should be encouraging "user-configurable" asset roots at all by default. Asset path logic should be determined by the app developer, not the app consumer. The defaults will work in 99.99% of cases and forcing standardization here (by default) is valuable from a tooling and ecosystem perspective.
If you want your game to support non-standard user-configurable asset paths, I think the correct solution is to use AssetServerSettings::asset_folder
(and maybe add a configurable custom_root_path: Option<PathBuf>
to the settings). You could wire that up to whatever environment variable you choose. And you could use whatever path processing logic you want (ex: canonicalize).
Closing this as I've got strong opinions (see my comment above). But feel free keep the conversation going. Happy to listen to counterarguments. |
Objective
CARGO_MANIFEST_DIR
, and it sets it as an absolute path.FileAssetIo
tends to crash with root set as relpath because of the same problem described here Filesystem watching crashes with symlinks pointing outside the asset folder #5689.Solution
CARGO_MANIFEST_DIR
when setting the root.