'Local crate in Rust
I am currently learning Rust, and for that purpose I wanted to create my own crate and use it. However, Rust can't find this crate.
I have the following file structure:
├───minimal
│ ├───Cargo.toml
│ └───src
│ └───main.rs
└───util
└───win
├───Cargo.toml
└───src
└───lib.rs
In folder minimal I have my main project. It looks like this:
Cargo.toml
[package]
name = "minimal"
version = "0.1.0"
[dependecies]
win = { path = "../util/win"}
main.rs
extern crate win; // ERROR: "Can't find crate for 'win' rustc(E0463)"
fn main() {
println!("Hello, World!");
}
My library in folder win looks like this:
File Cargo.toml
[package]
name = "win"
version = "0.1.0"
File lib.rs
pub type TestType = String;
My first assumption was that I somehow had a mistake in specifying the path in the dependency of the Cargo.toml file. So I tried to wiggle it around a bit, but it does not seem to work.
Rust reports
can't find crate for 'win' rustc(E0463)
I feel like I am making a very basic error here, however, when looking at similar questions (e.g., How do I "use" or import a local Rust file?) I can't seem to find it.
Solution 1:[1]
After having a good night's sleep and looking at this problem again, I have managed to find the error.
I used [dependecies]
instead of [dependencies]
in the Cargo.toml file.
On the one hand, I feel kind of dumb for this error, but on the other hand I now know that Cargo will not warn about unknown tags in the TOML file.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Peter Mortensen |