Andrey Arhipov
Andrey Arhipov

Reputation: 53

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.

Upvotes: 3

Views: 9042

Answers (2)

Jarosław Cichoń
Jarosław Cichoń

Reputation: 542

cargo install cargo-generate

error: failed to run custom build command for openssl-sys v0.9.87 ... It looks like you're compiling on Linux and also targeting Linux. Currently this requires the pkg-config utility to find OpenSSL but unfortunately pkg-config could not be found. If you have OpenSSL installed you can likely fix this by installing pkg-config.

', /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/openssl-sys-0.9.87/build/find_normal.rs:190:5 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace warning: build failed, waiting for other jobs to finish... error: failed to compile cargo-generate v0.18.3, intermediate artifacts can be found at /tmp/cargo-installguQK2f

TO FIX:

rm -rf /tmp/cargo-installcNl39M
apt install pkg-config
apt install libssl-dev

cargo install cargo-generate

Upvotes: 0

Scott
Scott

Reputation: 106

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

Upvotes: 9

Related Questions