How do I solve "error: no matching package named `` found"

Viewed 279

Goal: Fix the following error, and have my chain.rs file to be able to access the functions in the crypto.rs file.

crypto is a file in my project I created, not a external crate that can be found on https://crates.io/.

After entering: cargo run...

error: no matching package named `crypto` found
location searched: C:\Users\Administrator\Documents\---\fuzz\crypto
required by package `project v0.1.0 (C:\Users\Administrator\Documents\---\fuzz\chain)`

Background: I have a project and the directory looks like this. Directory Image

To reproduce this, download the repository here: https://github.com/LixurProtocol/Lixur. Then run chain.rs with cargo.

I want to import the contents from crypto.rs to chain.rs using this .toml file.

[package]
name = "project"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
crypto = { path = "../crypto" }
chrono = "0.4.19"
sha2 = "0.10.2"
thousands = "0.2.0"
random_choice = "0.3.2"
serde = { version = "1.0.140", features = ["derive"] }
serde_json = "1.0.82"

[[bin]]
name = "chain"
path = "src/chain.rs"

I've seen from this link (https://github.com/rust-lang/cargo/issues/6686) that I need a config.toml file but I can't find one on my device.

Things I've tried: Updating cargo, tracking down the location of my config.toml file (Couldn't find it anywhere)

So, how do I fix this? Do I make a config.toml file? How do I create one?

1 Answers

To use another crate as a dependency, it must be a library, and your crypto.rs file does look like a library. However, your crypto/Cargo.toml has it marked as a binary (notice the [[bin]] section).

To make it a library use [lib] instead.

Related