Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
865 views
in Technique[技术] by (71.8m points)

rust - cargo-generate install fail on Ubuntu 20.04

Trying to install cargo-generate on Ubuntu 20.04.1 LTS, first it complained about ssl, installed libssl with this command sudo apt-get install -y libssl-dev but now getting the error below.

How can I install cargo-generate on Ubuntu 20.04?

rustc --version
rustc 1.49.0 (e1884a8e3 2020-12-29)

cargo --version
cargo 1.49.0 (d00d64df9 2020-12-05)

cargo install cargo-generate
.....
   Compiling crypto-hash v0.3.4
   Compiling crates-io v0.31.1
   Compiling git2 v0.13.17
   Compiling git2-curl v0.14.1
   Compiling cargo v0.46.1
        error[E0283]: type annotations needed
           --> /home/username/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-0.46.1/src/cargo/util/config/de.rs:471:63
            |
        471 |                 seed.deserialize(Tuple2Deserializer(1i32, env.as_ref()))
            |                                                           ----^^^^^^--
            |                                                           |   |
            |                                                           |   cannot infer type for type parameter `T` declared on the trait `AsRef`
            |                                                           this method call resolves to `&T`
            |
            = note: cannot satisfy `std::string::String: AsRef<_>`
        
        error: aborting due to previous error
        
        For more information about this error, try `rustc --explain E0283`.
        error: failed to compile `cargo-generate v0.5.1`, intermediate artifacts can be found at `/tmp/cargo-installtb5LHS`
        
        Caused by:
          could not compile `cargo`
        
        To learn more, run the command again with --verbose.
question from:https://stackoverflow.com/questions/65894412/cargo-generate-install-fail-on-ubuntu-20-04

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This should (hopefully) be a temporary failure fixed in the cargo upstream (issue already closed).

Workaround:

cargo install cargo-generate --locked cargo

Failure and workaround described here: https://github.com/rust-lang/cargo/issues/9101


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...