cargo icon indicating copy to clipboard operation
cargo copied to clipboard

cargo install in a workspace gives confusing errors

Open Firstyear opened this issue 7 years ago • 8 comments

Problem

Running cargo install in a workspace gives a confusing error:

error: found a virtual manifest at `/Users/william/development/rsidm/Cargo.toml` instead of a package manifest

Attempting to use a manifest (which is what the common google searches tell you to do) also errors:

 cargo install --manifest-path kanidm_tools/Cargo.toml
error: Found argument '--manifest-path' which wasn't expected, or isn't valid in this context

This is because all the current online uses seem to be cargo build not cargo install (is anyone installing anything?).

As well, the other suggested option is --all: which also fails:

cargo install --all
error: Found argument '--all' which wasn't expected, or isn't valid in this context
	Did you mean --all-features?

Steps

  1. create a workspace with multiple members.
  2. in the workspace run "cargo install" 3.

Possible Solution(s) cargo install in a workspace could

  • give a better or constructive error such as "did you mean to use --path"?
  • make --all mean something
  • just work by default (install all binaries of the workspace)

Notes

Firstyear avatar Nov 17 '19 23:11 Firstyear

Somewhat of a duplicate of #4101 and #7124, but I'll leave this open since it is clearly written. :smile:

ehuss avatar Dec 03 '19 16:12 ehuss

now cargo install --path <binary_crate> works, it's great! my rustc version is rustc 1.43.1 (8d69840ab 2020-05-04), thanks your nice job!

denglitong avatar May 31 '20 12:05 denglitong

Any recent updates on this issue or plans of addressing it? I also ran into the confusion of trying to run cargo install from the root of my workspace and not understanding the error message. But it definitely would be nice if it behaved the same as cargo build from the workspace root behaves, where it acts upon all packages in the workspace.

plwalsh avatar Apr 07 '21 22:04 plwalsh

^^ re-up, agreed. Why would cargo build work but not cargo install? This seems like a bug.

PrismaPhonic avatar May 03 '21 21:05 PrismaPhonic

i get this error too...what is solution please?

ralyodio avatar Apr 29 '22 12:04 ralyodio

I tried cargo build and got this error: error: linking with cc failed: exit status: 1

ralyodio avatar Apr 29 '22 12:04 ralyodio

TLDR fix: specify the path to the executable package with --path <binary-package-path>, in my case:

cargo install --path packages_rs/nextclade-cli

Fixed this error:

$ cargo install                            
error: found a virtual manifest at `/Users/corneliusromer/code/nextclade/Cargo.toml` instead of a package manifest

For a repo with this structure where the current work directory is the root:

.
├── Cargo.toml
└── packages_rs
   ├── nextclade
      └── Cargo.toml
   ├── nextclade-cli
      └── Cargo.toml
   └── nextclade-web
      └── Cargo.toml

I totally agree that the error message should be more helpful. The bad error message is surprising given Rust's usually very helpful errors.

corneliusroemer avatar May 17 '23 11:05 corneliusroemer

#7194 is somewhat similar in that part of the problem is that path sources (both cargo install and dependencies) are non-recursive and we try to load that Cargo.toml itself.

epage avatar Nov 03 '23 03:11 epage