Skip to content
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

PWD and Cargo CARGO_MANIFEST inconsistency #2930

Closed
marvin-hansen opened this issue Oct 9, 2024 · 0 comments
Closed

PWD and Cargo CARGO_MANIFEST inconsistency #2930

marvin-hansen opened this issue Oct 9, 2024 · 0 comments

Comments

@marvin-hansen
Copy link
Contributor

In some case, rules_rust comes up with a different CARGO_MANIFEST location than Cargo.

For example, the Diesel migration macro depends on CARGO_MANIFEST to determine the path of the migration file to run. With Cargo, this works.

With Bazel, it only works when the crate is in the project root folder (don't ask me why), but it fails when the crate is somewhere deep down in the folder hirachy. I observed that issue several times in my repo.

After some digging, it seems rules_rust uses pwd internally to determine the working directory, which looks perfectly fine and plausible.
Except, there is a strange issue that causes PWD to point at a different location than CARGO_MANIFEST, but only under certain conditions.

See this discussion for details.

https://internals.rust-lang.org/t/build-scripts-pwd-and-cargo-manifest-dir-strangeness/16833

I didn't report it as bug back when it hit me the first time because a compiler macro relying on an environment variable isn't exactly hermetic so ultimately I replaced the macro altogether so I don't need the environment variable in the first place. This resolved the immediate issue, but obviously didn't addresses that PWD at times deviates from what Cargo cooks up.

It's possible that this inconsistency may cause other subtle bugs that are hard to pinpoint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant