rust - 从 GitHub 构建依赖箱时找不到 `Cargo.toml`

标签 rust rust-cargo

我正在尝试使用 rust-mosquitto library .我当前的 Cargo.toml 是:

[package]
name = "HomeDaemon"
version = "0.1.0"
authors = ["RTR <k.teza1@gmail.com>"]

[dependencies.mosquitto]
git = "https://github.com/kteza1/rust-mosquitto"

当我运行 cargo build 时,报告了以下错误:

Could not find `Cargo.toml` in `/Users/ravitejareddy/.cargo/git/checkouts/rust-mosquitto-8203e77dcf072bf7/rust-mosquitto`

~/.cargo/git/checkouts/rust-mosquitto-8203e77dcf072bf7/master 中的实际下载显示 Cargo.toml 存在。

上面的路径中多了一个rust-mosquitto,是不是有问题?

最佳答案

这并没有具体回答@tez 提出的问题,但我遇到了同样的错误,但根源略有不同。我在 vim 中写了一些简单的代码,所以我创建了一个简单的 main.rs 文件。当我 cargo run 它时,它吐出同样的错误:

error: could not find Cargo.toml in /Users/yvonmanzi/Documents/Rust or any parent directory

当然,事后看来,令人惊讶的是 rustc main.rs 正在按预期创建二进制可执行文件,而 cargo run 却没有。事实证明,到目前为止,我已经使用 cargo new project-name --bin 创建了我所有的 Rust 包(又名项目),如图所示 here ,因此默认包括 Cargo.lockCargo.tomlsrc 文件夹。希望现在很清楚,我的只是一个简单的菜鸟错误;从字面上看,我的项目文件夹中没有 Cargo.toml。所以,亲爱的新秀联盟 Rustacean,如果你遇到同样的错误,请使用 cargo new project-name --bin 命令创建你的项目。

关于rust - 从 GitHub 构建依赖箱时找不到 `Cargo.toml`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31571091/

相关文章:

hashmap - 如何在不依赖 Copy 特性的情况下在 Rust 中构建 Cacher?

indexing - 如何将范围作为 Rust 中的变量?

regex - 从字符串中删除所有空格

rust - Rust 的 Cargo 包可以在我的机器上编译代码吗?

rust - 如何获取字符的unicode值?

Rustc 仅在分配溢出的值时发出警告

rust - 即使在成功运行 `cargo build` 后编译时也无法找到 crate

rust - libwasm_bindgen-a2e136f9a24e6618.rlib 挂起,编译时不占用 CPU

rust - Cargo Clippy 抛出错误 'Question mark operator is useless here' - 建议可以实现吗?

datetime - 如何将 chrono::Datetime 舍入到最接近的秒数?