我正在尝试使用 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.lock
、Cargo.toml
和 src
文件夹。希望现在很清楚,我的只是一个简单的菜鸟错误;从字面上看,我的项目文件夹中没有 Cargo.toml
。所以,亲爱的新秀联盟 Rustacean,如果你遇到同样的错误,请使用 cargo new project-name --bin
命令创建你的项目。
关于rust - 从 GitHub 构建依赖箱时找不到 `Cargo.toml`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31571091/