Cargo install fails but compiling works

I have a cargo project with a top workspace with members. Building each works fine but when I try to install one with cargo install --path member I get errors:

error[E0432]: unresolved import `clap::Clap`
 --> remotebrowser/src/main.rs:1:5
  |
1 | use clap::Clap;
  |     ^^^^^^^^^^ no `Clap` in the root

error[E0432]: unresolved import `clap::Clap`
 --> remotebrowser/src/client/send/file.rs:1:5
  |
1 | use clap::Clap;
  |     ^^^^^^^^^^ no `Clap` in the root

error[E0432]: unresolved import `clap::Clap`
 --> remotebrowser/src/client/send/text.rs:1:5
  |
1 | use clap::Clap;
  |     ^^^^^^^^^^ no `Clap` in the root

error[E0432]: unresolved import `clap::Clap`
 --> remotebrowser/src/client/send/url.rs:1:5
  |
1 | use clap::Clap;
  |     ^^^^^^^^^^ no `Clap` in the root

error[E0432]: unresolved import `clap::Clap`
 --> remotebrowser/src/client/send.rs:7:5
  |
7 | use clap::Clap;
  |     ^^^^^^^^^^ no `Clap` in the root

error[E0432]: unresolved import `clap::Clap`
 --> remotebrowser/src/client/server_version.rs:1:5
  |
1 | use clap::Clap;
  |     ^^^^^^^^^^ no `Clap` in the root

error[E0432]: unresolved import `clap::Clap`
 --> remotebrowser/src/client/stop.rs:1:5
  |
1 | use clap::Clap;
  |     ^^^^^^^^^^ no `Clap` in the root

error[E0432]: unresolved import `clap::Clap`
 --> remotebrowser/src/client.rs:6:5
  |
6 | use clap::Clap;
  |     ^^^^^^^^^^ no `Clap` in the root

error[E0432]: unresolved import `clap::Clap`
 --> remotebrowser/src/server.rs:2:5
  |
2 | use clap::Clap;
  |     ^^^^^^^^^^ no `Clap` in the root

error[E0432]: unresolved import `clap::Clap`
 --> remotebrowser/src/ipaddresses.rs:1:5
  |
1 | use clap::Clap;
  |     ^^^^^^^^^^ no `Clap` in the root

error: cannot determine resolution for the derive macro `Clap`
  --> remotebrowser/src/client/send/file.rs:11:10
   |
11 | #[derive(Clap, Debug, Clone)]
   |          ^^^^
   |
   = note: import resolution is stuck, try simplifying macro imports

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/client/send/file.rs:18:4
   |
18 |     #[clap(long, default_value = remotebrowserlib::protocol::PORT)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/client/send/file.rs:21:4
   |
21 |     #[clap(long, default_value=remotebrowserlib::protocol::DEFAULT_IP_ADDRESS)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/client/send/file.rs:26:4
   |
26 |     #[clap(long, default_value = remotebrowserlib::protocol::TIMEOUT_MILLISECONDS)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/client/send/file.rs:29:4
   |
29 |     #[clap(long)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot determine resolution for the derive macro `Clap`
  --> remotebrowser/src/client/send/text.rs:10:10
   |
10 | #[derive(Clap, Debug, Clone)]
   |          ^^^^
   |
   = note: import resolution is stuck, try simplifying macro imports

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/client/send/text.rs:17:4
   |
17 |     #[clap(long, default_value = remotebrowserlib::protocol::PORT)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/client/send/text.rs:20:4
   |
20 |     #[clap(long, default_value=remotebrowserlib::protocol::DEFAULT_IP_ADDRESS)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/client/send/text.rs:25:4
   |
25 |     #[clap(long, default_value = remotebrowserlib::protocol::TIMEOUT_MILLISECONDS)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/client/send/text.rs:28:4
   |
28 |     #[clap(long)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot determine resolution for the derive macro `Clap`
  --> remotebrowser/src/client/send/url.rs:11:10
   |
11 | #[derive(Clap, Debug, Clone)]
   |          ^^^^
   |
   = note: import resolution is stuck, try simplifying macro imports

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/client/send/url.rs:18:4
   |
18 |     #[clap(long, default_value = remotebrowserlib::protocol::PORT)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/client/send/url.rs:21:4
   |
21 |     #[clap(long, default_value=remotebrowserlib::protocol::DEFAULT_IP_ADDRESS)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/client/send/url.rs:26:4
   |
26 |     #[clap(long, default_value = remotebrowserlib::protocol::TIMEOUT_MILLISECONDS)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/client/send/url.rs:31:4
   |
31 |     #[clap(long)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/client/send/url.rs:34:4
   |
34 |     #[clap(long)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot determine resolution for the derive macro `Clap`
  --> remotebrowser/src/client/send.rs:15:10
   |
15 | #[derive(Clap, Debug, Clone, Execute)]
   |          ^^^^
   |
   = note: import resolution is stuck, try simplifying macro imports

error: cannot determine resolution for the derive macro `Clap`
  --> remotebrowser/src/client/send.rs:23:10
   |
23 | #[derive(Clap, Debug, Clone, Execute)]
   |          ^^^^
   |
   = note: import resolution is stuck, try simplifying macro imports

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/client/send.rs:25:4
   |
25 |     #[clap(subcommand)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot determine resolution for the derive macro `Clap`
  --> remotebrowser/src/client/server_version.rs:14:10
   |
14 | #[derive(Clap, Debug, Clone)]
   |          ^^^^
   |
   = note: import resolution is stuck, try simplifying macro imports

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/client/server_version.rs:17:4
   |
17 |     #[clap(long, default_value = remotebrowserlib::protocol::PORT)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/client/server_version.rs:20:4
   |
20 |     #[clap(long, default_value=remotebrowserlib::protocol::DEFAULT_IP_ADDRESS)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/client/server_version.rs:25:4
   |
25 |     #[clap(long, default_value = remotebrowserlib::protocol::TIMEOUT_MILLISECONDS)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot determine resolution for the derive macro `Clap`
 --> remotebrowser/src/client/status.rs:8:10
  |
8 | #[derive(Clap, Debug, Clone)]
  |          ^^^^
  |
  = note: import resolution is stuck, try simplifying macro imports

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/client/status.rs:12:4
   |
12 |     #[clap(long, default_value = remotebrowserlib::protocol::PORT)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/client/status.rs:15:4
   |
15 |     #[clap(long, default_value=remotebrowserlib::protocol::DEFAULT_IP_ADDRESS)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/client/status.rs:20:4
   |
20 |     #[clap(long, default_value = remotebrowserlib::protocol::TIMEOUT_MILLISECONDS)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot determine resolution for the derive macro `Clap`
  --> remotebrowser/src/client/stop.rs:12:10
   |
12 | #[derive(Clap, Debug, Clone)]
   |          ^^^^
   |
   = note: import resolution is stuck, try simplifying macro imports

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/client/stop.rs:16:4
   |
16 |     #[clap(long, default_value = remotebrowserlib::protocol::PORT)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/client/stop.rs:19:4
   |
19 |     #[clap(long, default_value = remotebrowserlib::protocol::DEFAULT_IP_ADDRESS)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/client/stop.rs:24:4
   |
24 |     #[clap(long, default_value = remotebrowserlib::protocol::TIMEOUT_MILLISECONDS)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot determine resolution for the derive macro `Clap`
  --> remotebrowser/src/client.rs:18:10
   |
18 | #[derive(Clap, Debug, Clone, Execute)]
   |          ^^^^
   |
   = note: import resolution is stuck, try simplifying macro imports

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/client.rs:21:4
   |
21 |     #[clap(subcommand)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot determine resolution for the derive macro `Clap`
  --> remotebrowser/src/client.rs:27:10
   |
27 | #[derive(Clap, Debug, Clone, Execute)]
   |          ^^^^
   |
   = note: import resolution is stuck, try simplifying macro imports

error: cannot determine resolution for the derive macro `Clap`
  --> remotebrowser/src/server.rs:12:10
   |
12 | #[derive(Clap, Debug, Clone)]
   |          ^^^^
   |
   = note: import resolution is stuck, try simplifying macro imports

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/server.rs:17:4
   |
17 |     #[clap(long)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/server.rs:21:4
   |
21 |     #[clap(long)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/server.rs:25:4
   |
25 |     #[clap(long)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/server.rs:29:4
   |
29 |     #[clap(long)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/server.rs:33:4
   |
33 |     #[clap(long, default_value = remotebrowserlib::protocol::TIMEOUT_MILLISECONDS)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/server.rs:39:4
   |
39 |     #[clap(long, default_value = remotebrowserlib::protocol::DEFAULT_IP_ADDRESS)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/server.rs:43:4
   |
43 |     #[clap(long, default_value = remotebrowserlib::protocol::PORT)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/server.rs:48:4
   |
48 |     #[clap(long)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/server.rs:52:4
   |
52 |     #[clap(long)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/server.rs:61:4
   |
61 |     #[clap(long)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/server.rs:66:4
   |
66 |     #[clap(long)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/server.rs:71:4
   |
71 |     #[clap(long)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/server.rs:75:4
   |
75 |     #[clap(long)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot determine resolution for the derive macro `Clap`
 --> remotebrowser/src/ipaddresses.rs:8:10
  |
8 | #[derive(Clap, Debug, Clone)]
  |          ^^^^
  |
  = note: import resolution is stuck, try simplifying macro imports

error: cannot determine resolution for the derive macro `Clap`
  --> remotebrowser/src/main.rs:46:10
   |
46 | #[derive(Clap, Debug, Clone, Execute)]
   |          ^^^^
   |
   = note: import resolution is stuck, try simplifying macro imports

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/main.rs:47:3
   |
47 | #[clap(
   |   ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/main.rs:54:4
   |
54 |     #[clap(long)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/main.rs:57:4
   |
57 |     #[clap(long, default_value = "rust")]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/main.rs:61:4
   |
61 |     #[clap(subcommand)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/main.rs:66:4
   |
66 |     #[clap(long)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot find attribute `clap` in this scope
  --> remotebrowser/src/main.rs:70:4
   |
70 |     #[clap(long)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot determine resolution for the derive macro `Clap`
  --> remotebrowser/src/main.rs:75:10
   |
75 | #[derive(Clap, Debug, Clone, Execute)]
   |          ^^^^
   |
   = note: import resolution is stuck, try simplifying macro imports

error[E0599]: no function or associated item named `parse` found for struct `Options` in the current scope
   --> remotebrowser/src/main.rs:148:25
    |
52  | pub struct Options {
    | ------------------ function or associated item `parse` not found for this
...
148 |     let options = Options::parse();
    |                            ^^^^^ function or associated item not found in `Options`
    |
    = help: items from traits can only be used if the trait is implemented and in scope
    = note: the following trait defines an item `parse`, perhaps you need to implement it:
            candidate #1: `Parser`

Some errors have detailed explanations: E0432, E0599.
For more information about an error, try `rustc --explain E0432`.
error: failed to compile `remotebrowser v2.1.0 (/home/christian/Nextcloud/computer_sync_hardlink/RemoteBrowser/monorepo/rust/remotebrowser)`, intermediate artifacts can be found at `/home/christian/Nextcloud/computer_sync_hardlink/RemoteBrowser/monorepo/rust/target`

Caused by:
  could not compile `remotebrowser` due to 68 previous errors

My cargo version is

monorepo/rust$ cargo version
cargo 1.57.0 (b2e52d7ca 2021-10-21

I am on an Ubuntu 20.10 machine.

I remember running into something similar. Are you using git or path imports in your Cargo.toml?

1 Like

Tr adding --locked to the cargo install command. Otherwise Cargo.lock is ignored I believe.

2 Likes

Indeed I include the git hash in the final result, using git-version

this indeed worked thanks

So if I do cargo update the problem becomes reproducible for normal builds

error[E0432]: unresolved import `clap::Clap`
 --> features-metadata/src/main.rs:1:5
  |
1 | use clap::Clap;
  |     ^^^^^^^^^^ no `Clap` in the root

error: cannot determine resolution for the derive macro `Clap`
 --> features-metadata/src/main.rs:7:10
  |
7 | #[derive(Clap, Clone)]
  |          ^^^^
  |
  = note: import resolution is stuck, try simplifying macro imports

   Compiling rmversionnumbers v1.0.0 (/home/christian/Nextcloud/computer_sync_hardlink/RemoteBrowser/monorepo/rust/rmversionnumbers)
   Compiling from-str-enum v0.1.0 (/home/christian/Nextcloud/computer_sync_hardlink/RemoteBrowser/monorepo/rust/from-str-enum)
   Compiling toml v0.5.8
error[E0599]: no function or associated item named `parse` found for struct `Options` in the current scope
  --> features-metadata/src/main.rs:19:25
   |
8  | struct Options {
   | -------------- function or associated item `parse` not found for this
...
19 |     let options = Options::parse();
   |                            ^^^^^ function or associated item not found in `Options`
   |
   = help: items from traits can only be used if the trait is implemented and in scope
   = note: the following trait defines an item `parse`, perhaps you need to implement it:
           candidate #1: `Parser`

Some errors have detailed explanations: E0432, E0599.
For more information about an error, try `rustc --explain E0432`.
error: could not compile `features-metadata` due to 3 previous errors
warning: build failed, waiting for other jobs to finish...
error: build failed

These are not the same errors as for the install case actually; I guess something changed for macro resolution but I'm still on edition 2018 actually

Ok, so the problem seems that the API of Clap changes for 3.0 and I used the beta and the version resolver of cargo gets confused by beta and rc

So Clap changes the API for 3.0, and in between beta and rc the API changed again. cargo install picked the rc, and that led to the errors

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.