I can't install cargo-generate with build failed

Hi, rustacean!
I tried to install cargo-generate by cargo install cargo-generate command, but I couldn't install cargo-generate with the error (Captured image below).

It said look like this

error[E0658]: `if` is not allowed in a `const fn`
   --> /home/nao/.cargo/registry/src/github.com-1ecc6299db9ec823/sized-chunks-0.6.4/src/inline_array/mod.rs:117:5
    |
117 | /     if element_size == 0 {
118 | |         usize::MAX
119 | |     } else if element_align <= container_align && host_size > header_size {
120 | |         (host_size - header_size) / element_size
121 | |     } else {
122 | |         0 // larger alignment can't be guaranteed, so it'd be unsafe to store any elements
123 | |     }
    | |_____^
    |
    = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information

error[E0658]: `if` is not allowed in a `const fn`
   --> /home/nao/.cargo/registry/src/github.com-1ecc6299db9ec823/sized-chunks-0.6.4/src/inline_array/mod.rs:119:12
    |
119 |       } else if element_align <= container_align && host_size > header_size {
    |  ____________^
120 | |         (host_size - header_size) / element_size
121 | |     } else {
122 | |         0 // larger alignment can't be guaranteed, so it'd be unsafe to store any elements
123 | |     }
    | |_____^
    |
    = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0658`.
error: could not compile `sized-chunks`.

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: failed to compile `cargo-generate v0.6.0`, intermediate artifacts can be found at `/tmp/cargo-installxvPOf1`

Caused by:
  build failed

My Environment

Ubuntu(20.04LTS)
Rust: 1.45.0 (I tried both stable and nightly versions)

I would be very grateful if anyone could help me.
Thank you for reading this to the end.

This code requires Rust 1.46 or later. It looks like Rust 1.47 is currently available in the official Ubuntu repositories.

Run rustc --version to double-check which Rust toolchain you are running. If you installed Rust through both the Ubuntu package and the rustup tool, try uninstalling the Ubuntu version to ensure the rustup version is used.

1 Like

Thank you for replying.
I was able to install cargo-generate after I updated cargo and rustc.

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.