jdrouet/mrml

mrml-cli crate fails to compile when installed

Monkatraz opened this issue ยท 4 comments

Installing the mrml-cli crate yields a bunch of compile errors due to Clap macros:

monkatraz@pop-os:~$ cargo install mrml-cli
    Updating crates.io index
  Installing mrml-cli v1.3.2
   Compiling libc v0.2.110
   Compiling proc-macro2 v1.0.33
   Compiling cfg-if v1.0.0
   Compiling unicode-xid v0.2.2
   Compiling memchr v2.4.1
   Compiling syn v1.0.82
   Compiling serde_derive v1.0.131
   Compiling ryu v1.0.6
   Compiling serde v1.0.131
   Compiling autocfg v1.0.1
   Compiling log v0.4.14
   Compiling serde_json v1.0.72
   Compiling ppv-lite86 v0.2.15
   Compiling termcolor v1.1.2
   Compiling regex-syntax v0.6.25
   Compiling itoa v0.4.8
   Compiling hashbrown v0.11.2
   Compiling bitflags v1.3.2
   Compiling xmlparser v0.13.3
   Compiling textwrap v0.14.2
   Compiling humantime v2.1.0
   Compiling strsim v0.10.0
   Compiling indexmap v1.7.0
   Compiling aho-corasick v0.7.18
   Compiling os_str_bytes v6.0.0
   Compiling getrandom v0.2.3
   Compiling atty v0.2.14
   Compiling quote v1.0.10
   Compiling rand_core v0.6.3
   Compiling clap v3.0.0-rc.3
   Compiling rand_chacha v0.3.1
   Compiling regex v1.5.4
   Compiling rand v0.8.4
   Compiling env_logger v0.8.4
   Compiling mrml v1.2.6
   Compiling mrml-cli v1.3.2
error[E0432]: unresolved imports `clap::crate_authors`, `clap::crate_description`, `clap::crate_name`, `clap::crate_version`, `clap::Clap`
 --> /home/monkatraz/.cargo/registry/src/github.com-1ecc6299db9ec823/mrml-cli-1.3.2/src/main.rs:1:12
  |
1 | use clap::{crate_authors, crate_description, crate_name, crate_version, Clap};
  |            ^^^^^^^^^^^^^  ^^^^^^^^^^^^^^^^^  ^^^^^^^^^^  ^^^^^^^^^^^^^  ^^^^ no `Clap` in the root
  |            |              |                  |           |
  |            |              |                  |           no `crate_version` in the root
  |            |              |                  no `crate_name` in the root
  |            |              no `crate_description` in the root
  |            no `crate_authors` in the root

error: cannot determine resolution for the derive macro `Clap`
 --> /home/monkatraz/.cargo/registry/src/github.com-1ecc6299db9ec823/mrml-cli-1.3.2/src/main.rs:8:10
  |
8 | #[derive(Clap)]
  |          ^^^^
  |
  = note: import resolution is stuck, try simplifying macro imports

error: cannot find attribute `clap` in this scope
 --> /home/monkatraz/.cargo/registry/src/github.com-1ecc6299db9ec823/mrml-cli-1.3.2/src/main.rs:9:3
  |
9 | #[clap(name = crate_name!(), about = crate_description!(), version = crate_version!(), author = crate_authors!())]
  |   ^^^^
  |
  = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot find attribute `clap` in this scope
  --> /home/monkatraz/.cargo/registry/src/github.com-1ecc6299db9ec823/mrml-cli-1.3.2/src/main.rs:11:7
   |
11 |     #[clap(subcommand)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot find attribute `clap` in this scope
  --> /home/monkatraz/.cargo/registry/src/github.com-1ecc6299db9ec823/mrml-cli-1.3.2/src/main.rs:13:7
   |
13 |     #[clap(about = "Path to your mjml file", index = 1)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot determine resolution for the derive macro `Clap`
  --> /home/monkatraz/.cargo/registry/src/github.com-1ecc6299db9ec823/mrml-cli-1.3.2/src/main.rs:78:10
   |
78 | #[derive(Clap)]
   |          ^^^^
   |
   = note: import resolution is stuck, try simplifying macro imports

error: cannot find attribute `clap` in this scope
  --> /home/monkatraz/.cargo/registry/src/github.com-1ecc6299db9ec823/mrml-cli-1.3.2/src/main.rs:80:7
   |
80 |     #[clap(about = "Format template to JSON")]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot find attribute `clap` in this scope
  --> /home/monkatraz/.cargo/registry/src/github.com-1ecc6299db9ec823/mrml-cli-1.3.2/src/main.rs:82:7
   |
82 |     #[clap(about = "Format template to MJML")]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot find attribute `clap` in this scope
  --> /home/monkatraz/.cargo/registry/src/github.com-1ecc6299db9ec823/mrml-cli-1.3.2/src/main.rs:84:7
   |
84 |     #[clap(about = "Render template to HTML")]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot find attribute `clap` in this scope
  --> /home/monkatraz/.cargo/registry/src/github.com-1ecc6299db9ec823/mrml-cli-1.3.2/src/main.rs:86:7
   |
86 |     #[clap(about = "Read input file and validate its structure")]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot determine resolution for the derive macro `Clap`
   --> /home/monkatraz/.cargo/registry/src/github.com-1ecc6299db9ec823/mrml-cli-1.3.2/src/main.rs:122:10
    |
122 | #[derive(Clap)]
    |          ^^^^
    |
    = note: import resolution is stuck, try simplifying macro imports

error: cannot find attribute `clap` in this scope
   --> /home/monkatraz/.cargo/registry/src/github.com-1ecc6299db9ec823/mrml-cli-1.3.2/src/main.rs:124:7
    |
124 |     #[clap(long, about = "Pretty print")]
    |       ^^^^
    |
    = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot determine resolution for the derive macro `Clap`
   --> /home/monkatraz/.cargo/registry/src/github.com-1ecc6299db9ec823/mrml-cli-1.3.2/src/main.rs:128:10
    |
128 | #[derive(Clap)]
    |          ^^^^
    |
    = note: import resolution is stuck, try simplifying macro imports

error: cannot find attribute `clap` in this scope
   --> /home/monkatraz/.cargo/registry/src/github.com-1ecc6299db9ec823/mrml-cli-1.3.2/src/main.rs:130:7
    |
130 |     #[clap(short, long, about = "Remove comments from html output")]
    |       ^^^^
    |
    = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot find attribute `clap` in this scope
   --> /home/monkatraz/.cargo/registry/src/github.com-1ecc6299db9ec823/mrml-cli-1.3.2/src/main.rs:132:7
    |
132 |     #[clap(short, long, about = "Base url for social icons")]
    |       ^^^^
    |
    = note: `clap` is in scope, but it is a crate, not an attribute

error[E0599]: no function or associated item named `parse` found for struct `Options` in the current scope
   --> /home/monkatraz/.cargo/registry/src/github.com-1ecc6299db9ec823/mrml-cli-1.3.2/src/main.rs:147:14
    |
10  | struct Options {
    | -------------- function or associated item `parse` not found for this
...
147 |     Options::parse().execute();
    |              ^^^^^ 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 traits define an item `parse`, perhaps you need to implement one of them:
            candidate #1: `StructOpt`
            candidate #2: `mrml::prelude::parse::Parser`
            candidate #3: `Parsable`

Some errors have detailed explanations: E0432, E0599.
For more information about an error, try `rustc --explain E0432`.
error: failed to compile `mrml-cli v1.3.2`, intermediate artifacts can be found at `/tmp/cargo-installNJHxMH`

Caused by:
  could not compile `mrml-cli` due to 16 previous errors

Here are my cargo and rustc versions, if that is of any help:

cargo 1.57.0 (b2e52d7ca 2021-10-21)
rustc 1.57.0 (f1edd0429 2021-11-29)

Thanks for that issue! I'll take a look at it this weekend ๐Ÿ˜‰

@Monkatraz you're right it's failing when I install it like following

docker run --rm -it rust:bullseye cargo install mrml-cli

But if you lock the versions (as I should have documented ๐Ÿ˜‰

docker run --rm -it rust:bullseye cargo install --locked mrml-cli

It works.

If you want to install it, try to run cargo install --locked mrml-cli.

Thank you again for noticing that ๐Ÿ˜‰

Noting I can also reproduce this issue. Seeing how there isn't a Cargo.lock file, is that related?

@ammongit considering it's a workspace, the Cargo.lock is located at the root level ๐Ÿ˜‰