将我已经使用过的所有依赖项写到cargo.lock
中,甚至包括其他项目的依赖项!
喜欢这个:
# my project's cargo.toml
[package]
name = "auto-commander"
version = "0.0.1"
authors = ["kkocdko"]
edition = "2018"
[dependencies]
toml = "0.5.5"
# my project's cargo.lock
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "auto-commander"
version = "0.0.1"
dependencies = [
"toml 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "autocfg"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "bitflags"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "byteorder"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
# ... and so many other useless item
我确定我的眼睛很好,有很多无用的项目,而不是依赖项的依赖项。
我阅读了这些物品,它们都是我在其他项目中使用过的箱子。
编译结果没有例外,只是Cargo.lock
的问题。
我应该如何处理?
平台:
windows 10.0.14393
rustup 1.21.1 (7832b2ebe 2019-12-20)
cargo 1.40.0 (bc8e4c8be 2019-11-22)
rustc 1.40.0 (73528e339 2019-12-16)
根据用户2722968的建议,您可以使用https://crates.io/crates/cargo-tree检查依赖项来自何处
我重新安装了Rust的工具链,这个奇怪的问题消失了。但为什么?我很困惑。这是有关缓存的错误吗?
现在Cargo.lock
的全部内容是:
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "auto-commander"
version = "0.0.1"
dependencies = [
"toml 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "serde"
version = "1.0.104"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "toml"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
]
[metadata]
"checksum serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449"
"checksum toml 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "01d1404644c8b12b16bfcffa4322403a91a451584daaaa7c28d3152e6cbc98cf"
完全正常。