rust-lang / rust-lang/cargo

Environment variable for Cargo Workspace for finding workspace-wide assets

Open
#3,946 72 comments 108 reactions 1 assignee View on GitHub

@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
  • 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


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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.