6

我正在尝试使用rust-mosquitto 库。我目前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上面的路径中有一个额外的,有问题吗?

4

3 回答 3

6

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

Cargo.toml错误:在/Users/yvonmanzi/Documents/Rust或任何父目录中找不到

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

于 2020-06-13T14:22:05.237 回答
5

问题来自您的Cargo.tomlin examples/ticktock

[dependencies.mosquitto]
version = "*"
path = "../../../rust-mosquitto" 

从 git 下载项目时,会扫描所有子目录以查找更多Cargo.toml文件。如果你运行RUST_LOG=trace cargo build -v,你会看到发生了什么:

TRACE:cargo::ops::cargo_read_manifest: looking for root package: /Users/shep/.cargo/git/checkouts/rust-mosquitto-77eb7033f32b19c9/master, source_id=https://github.com/kteza1/rust-mosquitto#7e08a291
TRACE:cargo::ops::cargo_read_manifest: looking for child package: /Users/shep/.cargo/git/checkouts/rust-mosquitto-77eb7033f32b19c9/master
TRACE:cargo::ops::cargo_read_manifest: read_package; path=/Users/shep/.cargo/git/checkouts/rust-mosquitto-77eb7033f32b19c9/master/Cargo.toml; source-id=https://github.com/kteza1/rust-mosquitto#7e08a291
TRACE:cargo::ops::cargo_read_manifest: looking for child package: /Users/shep/.cargo/git/checkouts/rust-mosquitto-77eb7033f32b19c9/master/.git
TRACE:cargo::ops::cargo_read_manifest: not processing /Users/shep/.cargo/git/checkouts/rust-mosquitto-77eb7033f32b19c9/master/.git
TRACE:cargo::ops::cargo_read_manifest: looking for child package: /Users/shep/.cargo/git/checkouts/rust-mosquitto-77eb7033f32b19c9/master/examples
TRACE:cargo::ops::cargo_read_manifest: looking for child package: /Users/shep/.cargo/git/checkouts/rust-mosquitto-77eb7033f32b19c9/master/examples/c-mosquitto
TRACE:cargo::ops::cargo_read_manifest: looking for child package: /Users/shep/.cargo/git/checkouts/rust-mosquitto-77eb7033f32b19c9/master/examples/ticktock
TRACE:cargo::ops::cargo_read_manifest: read_package; path=/Users/shep/.cargo/git/checkouts/rust-mosquitto-77eb7033f32b19c9/master/examples/ticktock/Cargo.toml; source-id=https://github.com/kteza1/rust-mosquitto#7e08a291
DEBUG:cargo: handle_error; err=CliError { error: ChainedError { error: Unable to update https://github.com/kteza1/rust-mosquitto, cause: Could not find `Cargo.toml` in `/Users/shep/.cargo/git/checkouts/rust-mosquitto-77eb7033f32b19c9/rust-mosquitto` }, unknown: false, exit_code: 101 }

Cargo 然后尝试确保嵌套Cargo.toml可以满足所有依赖项。

于 2015-07-22T23:29:15.157 回答
0

在我在程序/脚本下执行那些 *.sh 后它起作用了(然后再次货物 build-bp )

于 2021-12-08T07:11:34.443 回答