Bikas Lin
Bikas Lin

Reputation: 730

How to solve error: no such subcommand: `generate`

I have installed rust using curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh on Ubuntu.

But when I tried cargo generate --git https://github.com/CosmWasm/cw-template.git --name FOO I met the error like this error: no such subcommand: 'generate'

My cargo version is cargo 1.59.0 (49d8809dc 2022-02-10).

Why this happens?

Upvotes: 11

Views: 8196

Answers (2)

gnu_byte
gnu_byte

Reputation: 41

So turns out that even today cargo add <package> is not an official command. Its part of cargo edit. It is going to be added in the next Rust update supposedly. For now you have to edit the Cargo.toml file the old fashioned way.

Edit: to install and have the ability to use add subcommand now, run cargo install cargo-edit

Upvotes: 0

You should install the cargo-generate with:

cargo install cargo-generate

Some cargo sub commands are built in, while others are installed separately. You can get the list of available sub commands with:

cargo --list

Upvotes: 17

Related Questions