Q: Build script is unable to find crate that is listed in the [dependencies] section Minimal reproducible example:
build.rs
extern crate pkg_config;

fn main() {}

Cargo.toml
[dependencies]
pkg-config = "0.3"

Running cargo check or cargo build on this example results in an error: error[E0463]: can't find crate for pkg_config.
Cargo downloaded the crate just fine and I've verified that I have pkg-config installed. Is there some rule I'm missing about build.rs dependencies? Is there some other configuration I need specifically for pkg-config?

A: Instead of pkg-config under [dependencies], you need to list it under [build-dependencies] in your Cargo.toml file. Cargo differentiates between the two. The first is for the app or library, while the [build-dependencies] are for the build.rs script.
