cargo-generate 安装在 Ubuntu 20.04 上失败

cargo-generate install fail on Ubuntu 20.04

尝试在 Ubuntu 20.04.1 LTS 上安装 cargo-generate,首先它抱怨 ssl,使用此命令安装 libssl sudo apt-get install -y libssl-dev 但现在出现以下错误。

如何在 Ubuntu 20.04 上安装 cargo-generate?

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.

这应该(希望)是货物上游修复的临时故障(问题已经关闭)。

解决方法:

cargo install cargo-generate --locked cargo

此处描述的失败和解决方法:https://github.com/rust-lang/cargo/issues/9101