How to build a new Rust project with Serde crate (v.1.0.189) as dependency

118 views Asked by At

I'm trying to develop a simple feature in a new Rust project and every time that I add the serde crate (https://crates.io/crates/serde) my build stops working. Not sure why. At the bottom of the command there is a "No such file or directory (os error 2)" message. But that is a clean install using rustup. Can that be related?

That's the output:

$ cargo build -vv
   Dirty proc-macro2 v1.0.69: stale, unknown reason
   Compiling proc-macro2 v1.0.69
       Fresh unicode-ident v1.0.12
     Running `CARGO=/home/rodrigosilva/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo CARGO_CRATE_NAME=build_script_build CARGO_MANIFEST_DIR=/home/rodrigosilva/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-1.0.69 CARGO_PKG_AUTHORS='David Tolnay <[email protected]>:Alex Crichton <[email protected]>' CARGO_PKG_DESCRIPTION='A substitute implementation of the compiler'\''s `proc_macro` API to decouple token-based libraries from the procedural macro use case.' CARGO_PKG_HOMEPAGE='' CARGO_PKG_LICENSE='MIT OR Apache-2.0' CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=proc-macro2 CARGO_PKG_README=README.md CARGO_PKG_REPOSITORY='https://github.com/dtolnay/proc-macro2' CARGO_PKG_RUST_VERSION=1.56 CARGO_PKG_VERSION=1.0.69 CARGO_PKG_VERSION_MAJOR=1 CARGO_PKG_VERSION_MINOR=0 CARGO_PKG_VERSION_PATCH=69 CARGO_PKG_VERSION_PRE='' LD_LIBRARY_PATH='/home/rodrigosilva/git/serde-test/target/debug/deps:/home/rodrigosilva/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib:/home/rodrigosilva/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib' /home/rodrigosilva/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc --crate-name build_script_build --edition=2021 /home/rodrigosilva/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-1.0.69/build.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=213 --crate-type bin --emit=dep-info,link -C embed-bitcode=no --cfg 'feature="default"' --cfg 'feature="proc-macro"' -C metadata=984fd110d6c25c2b -C extra-filename=-984fd110d6c25c2b --out-dir /home/rodrigosilva/git/serde-test/target/debug/build/proc-macro2-984fd110d6c25c2b -L dependency=/home/rodrigosilva/git/serde-test/target/debug/deps --cap-lints warn`
     Running `/home/rodrigosilva/git/serde-test/target/debug/build/proc-macro2-984fd110d6c25c2b/build-script-build`
error: failed to run custom build command for `proc-macro2 v1.0.69`

Caused by:
  could not execute process `/home/rodrigosilva/git/serde-test/target/debug/build/proc-macro2-984fd110d6c25c2b/build-script-build` (never executed)

Caused by:
  No such file or directory (os error 2)

I created a new project from scratch: new folder, cargo init, cargo add serde and then cargo build. In this completely isolated environment I expected that it'd build without any errors.

0

There are 0 answers