-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Relative cargo:rerun-if-changed paths are not resolved in dep-info files #9445
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Thanks for the report! This should be fixed via #9421, which I think should be in the next nightly tomorrow. If you would like to extend the documentation to mention things that tools should be aware of (like environment variables), a PR would be appreciated! |
Ohh missed that, but great it's already fixed! I'll try tomorrow/in the next few days with the new nightly. One issue that might still exist is that the absolute path to the |
Just tried it out with the current nightly (
So it's working 🎉 ! However, the absolute path to the |
@ehuss ping; just wanted to ask if you want me to leave the issue open/open another issue for the small detail from my last comment, otherwise this is fixed, thanks a lot! :) |
I'd like to keep it open to investigate what you mentioned, I haven't had time to take a look. It seems a little surprising, though I can't imagine it would have negative consequences, I'd like to understand it better. |
Problem
If I have a dependency that has a
build.rs
build script that outputs a relative path (e.g.,cargo:rerun-if-changed=build.rs
), this path will appear unchanged in dep info files of my crate.This path can then not be resolved by external build tools.
Steps
cargo new --bin dep-info-test && cd dep-info-test
)cargo:rerun-if-changed=<relative path>
, e.g., libc:echo 'libc = "0.2"' >> Cargo.toml
cargo build && cat target/debug/dep-info-test.d
:Possible Solution(s)
It seems that
cargo
's internal change-detection mechanism (something with fingerprints?) resolves relative paths output by build scripts as relative to theirCARGO_MANIFEST_DIR
(I think), which should probably explicitly also be done for dep-info files.Also, in the case of crates.io- & git-dependencies,
cargo
doesn't write paths to the dependencies' files itself into the dep-info file, as it regards such dependencies as 'read-only'. So for non-path dependencies absolute paths that point into a dependency'sCARGO_MANIFEST_DIR
should probably not appear in dep-info files anymore (but should still appear for path-dependencies).Notes
Output of
cargo version
:Same behavior with current stable:
Extra discussion material
I think the dep-info files are currently misleading, as they don't capture all conditions under which
cargo
needs to rebuild a project. For example, environment variables registered usingcargo:rerun-if-env-changed
are not captured in this file. Another example are.cargo/config
files, which often don't exist, but influence compilation, so they would need to be in every dep-info file. These can also appear outside the project, i.e., in every parent directory down to the root-directory.The fact that this file is incomplete is not mentioned in the current docs, but maybe should be mentioned there.
The text was updated successfully, but these errors were encountered: