You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
The text was updated successfully, but these errors were encountered:
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.
The text was updated successfully, but these errors were encountered: