如何解决错误:没有这样的子命令:`generate`
我已经使用curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs |安装了rust在 Ubuntu 上使用 sh。
但是当我尝试 cargogenerate --git https://github.com/CosmWasm/cw-template.git --name FOO
时,我遇到了这样的错误 error: no such subcommand: 'generate'
我的货物版本是cargo 1.59.0 (49d8809dc 2022-02-10)
。
为什么会出现这种情况?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该安装
cargo-generate
:一些 Cargo 子命令是内置的,而其他子命令是单独安装的。您可以通过以下方式获取可用子命令的列表:
You should install the
cargo-generate
with:Some cargo sub commands are built in, while others are installed separately. You can get the list of available sub commands with:
事实证明,即使在今天,
cargo add
也不是官方命令。它是货物编辑的一部分。据说它将在下一个 Rust 更新中添加。现在,您必须以老式方式编辑Cargo.toml
文件。编辑:要安装并现在能够使用添加子命令,请运行
cargo install Cargo-edit
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 theCargo.toml
file the old fashioned way.Edit: to install and have the ability to use add subcommand now, run
cargo install cargo-edit