Environment variable for Cargo Workspace for finding workspace-wide assets
Open
@yerke is already working on this.
Since May 17, 2023.
A-environment-variables
A-workspaces
C-feature-request
S-needs-design
- Dominant language
- Rust
- Stars
- 15.5k
- Forks
- 3k
- Avg merge
- 23h 30m
- Merged PRs (30d)
- 51
Description
T-cargo notes:
Potential use cases:
- Accessing workspace-wide assets (this issue)
- Looking up
file!at test runtime, see #15885 - Finding a binary's path, see
CARGO_BIN_EXE_<name>- #9661
- Looking up the lockfile, this would be insufficient because the lockfile path can be overridden. A new issue for this would be needed.
- Dependencies looking up information in your workspace: side-banned communication like this is rejected by the cargo team
Updates
- https://github.com/rust-lang/cargo/issues/3946#issuecomment-1402464796
- https://github.com/rust-lang/cargo/issues/3946#issuecomment-3224923131
Hi, while working on using workspace in html5ever, I've ran into issue of needing the CARGO_WORKSPACE directory, and being unable, to find it. What I resorted to is essentially, &Path(cargo_manifest).join("..") which feels hacky.
Could CARGO_WORKSPACE be added as environment variable? I'm not sure what it should be when there is no workspace defined, I assume it should either return Err or default it to CARGO_MANIFEST_DIR.
Sidenote I'm willing to work on this issue, if I could get quick pointers, to what I need to do.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.