如何解决错误:没有这样的子命令:`generate`

发布于 2025-01-14 23:05:46 字数 342 浏览 2 评论 0原文

我已经使用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浅忆 2025-01-21 23:05:46

您应该安装 cargo-generate

cargo install cargo-generate

一些 Cargo 子命令是内置的,而其他子命令是单独安装的。您可以通过以下方式获取可用子命令的列表:

cargo --list

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
何必那么矫情 2025-01-21 23:05:46

事实证明,即使在今天,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 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文