Closed
Description
Problem
cargo install --path
can give spurious errors when run from inside a workspace or existing package if the path being installed is not in the workspace.
Steps
git clone https://github.com/hyperium/mime
git clone https://github.com/deadlinks/cargo-deadlinks
cd mime
cargo install --path ../cargo-deadlinks
error: current package believes it's in a workspace when it's not:
current: /home/jnelson/rust-community/mime/../cargo-deadlinks/Cargo.toml
workspace: /home/jnelson/rust-community/mime/Cargo.toml
this may be fixable by adding `../cargo-deadlinks` to the `workspace.members` array of the manifest located at: /home/jnelson/rust-community/mime/Cargo.toml
Alternatively, to keep it out of the workspace, add the package to the `workspace.exclude` array, or add an empty `[workspace]` table to the package's manifest.
The original error I got was slightly different, but is harder to replicate and I suspect is caused by the same underlying issue:
$ cargo install --locked --path ../redacted/lib/integration-tests
error: package `/home/jnelson/work/redacted/bin/test/Cargo.toml` is a member of the wrong workspace
expected: /home/jnelson/work/redacted-2/../redacted/Cargo.toml
actual: /home/jnelson/work/redacted/Cargo.toml
Possible Solution(s)
Cargo should ignore the current workspace when running cargo install
.
Notes
No response
Version
cargo 1.59.0-nightly (fcef61230 2021-12-17)
release: 1.59.0-nightly
commit-hash: fcef61230c3b6213b6b0d233a36ba4ebd1649ec3
commit-date: 2021-12-17
host: x86_64-unknown-linux-gnu
libgit2: 1.3.0 (sys:0.13.23 vendored)
libcurl: 7.80.0-DEV (sys:0.4.51+curl-7.80.0 vendored ssl:OpenSSL/1.1.1l)
os: Pop!_OS 20.04 (focal) [64-bit]