Stream: general

Topic: cargo-workspace-root-env


csmoe (Jul 03 2019 at 11:10, on Zulip):

for a workspace:

workspace -
   - Cargo.toml
   - crate_a
      - Cargo.toml
      - build.rs
   - crate_b

@matklad is there any method for crate_a/build.rs to get the workspace's root path with env variable? CARGO_MANIFEST_DIR can only return the path of crate_a.

matklad (Jul 03 2019 at 11:17, on Zulip):

IIRC, that's not possible in a good. I remember facing the same issue with insta. The workaround is to call cargo metadata from build.rs

csmoe (Jul 03 2019 at 11:18, on Zulip):

@matklad thanks :slight_smile:
is it suitable to post a feature request to cargo repo?

matklad (Jul 03 2019 at 11:21, on Zulip):

Yeah, I think CARGO_WORKSPACE_MANIFEST_DIR is a reasonable thing to add to Cargo. The insta issue was https://github.com/mitsuhiko/insta/issues/1

Last update: Nov 21 2019 at 23:35UTC