Cargo build will not compile

I am on a MacBook. Following the tutorial. Stuck on the guessing_game after addding dependcies...

Script started on Sun Apr 20 19:10:53 2025
ESC[1mESC[7m%ESC[27mESC[1mESC[0m
^M ^MESC]7;file://MacBook-Air-van-Andre.local/Users/andre/Speeltuin/Rust/projects/guessing_game^G^MESC[0mESC[27mESC[24mESC[Jandre@MacBook
-Air-van-Andre guessing_game % ESC[KESC[?2004hcargo buildESC[?2004l
ESC[1mESC[32m CompilingESC[0m libc v0.2.172
ESC[1mESC[32m CompilingESC[0m zerocopy v0.8.24
ESC[1mESC[36m BuildingESC[0m [========> ] 5/15: zerocopy(build), libc(build)
^MESC[KESC[1mESC[31merrorESC[0mESC[1m:ESC[0m failed to run custom build command for libc v0.2.172

Caused by:
process didn't exit successfully: /Users/andre/Speeltuin/Rust/projects/guessing_game/target/debug/build/libc-199c8bfe631320b5/build-script-build (exit status: 101)
--- stdout
cargo:rerun-if-changed=build.rs

--- stderr

thread 'main' panicked at /Users/andre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.172/build.rs:173:9:
failed to run rustc:
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
ESC[1mESC[33mwarningESC[0mESC[1m:ESC[0m build failed, waiting for other jobs to finish...
ESC[1mESC[36m BuildingESC[0m [==========> ] 6/15: zerocopy(build) ^MESC[KESC[1mESC[31merrorESC[0mESC[1m:ESC[0m failed to run custom build command for zerocopy v0.8.24

Caused by:
process didn't exit successfully: /Users/andre/Speeltuin/Rust/projects/guessing_game/target/debug/build/zerocopy-93d86abaa41e2c0a/build-script-build (exit status: 101)
--- stdout
cargo:rerun-if-changed=build.rs
cargo:rerun-if-changed=Cargo.toml

--- stderr

thread 'main' panicked at /Users/andre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/zerocopy-0.8.24/build.rs:221:9:
rustc failed with status: signal: 9 (SIGKILL)
rustc output:
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
ESC[1mESC[7m%ESC[27mESC[1mESC[0m ^M ^MESC]7;file://MacBook-Air-van-Andre.local/Users/andre/Speeltuin/Rust/projects/guessing_game^G^MESC[0mESC[27mESC[24mESC[Jandre@MacBook-Air-van-Andre guessing_game % ESC[KESC[?2004hD
ESC[JDeRez DevToolsSecurity DirectoryServiceESC[AESC[0mESC[27mESC[24m^MESC[44CDESC[ESC[?2004l
ESC[JESC[1mESC[7m%ESC[27mESC[1mESC[0m ^M ^MESC]7;file://MacBook-Air-van-Andre.local/Users/andre/Speeltuin/Rust/projects/guessing_game^G^MESC[0mESC[27mESC[24mESC[Jandre@MacBook-Air-van-Andre guessing_game % ESC[KESC[?2004hESC[?2004l
ESC[1mESC[7m%ESC[27mESC[1mESC[0m ^M ^MESC]7;file://MacBook-Air-van-Andre.local/Users/andre/Speeltuin/Rust/projects/guessing_game^G^MESC[0mESC[27mESC[24mESC[Jandre@MacBook-Air-van-Andre guessing_game % ESC[KESC[?2004hESC[?2004l

Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.

Script done on Sun Apr 20 19:11:43 2025

What happens if you manually try to run /Users/andre/Speeltuin/Rust/projects/guessing_game/target/debug/build/libc-199c8bfe631320b5/build-script-build?

Which rustc version do you have installed? (rustc -vV)

Sorry that this error printed by Cargo is so messy and unreadable. In all that noise, the only relevant line is:

rustc failed with status: signal: 9 (SIGKILL)

On macOS this may be happening due to multiple reasons. Most often:

  • The system is low on memory. Reboot your Mac.

  • Apple's Gatekeeper for some reason to keep Rust in a "quarantine". The quickest solution may be to delete Rust completely and reinstall it (rm -rf ~/.cargo ~/.rustup and then reinstall via https://rustup.rs). This could be more robust if rustup/cargo was code signed.

1 Like

I know it's messy... That's why I am lost...
I did a reinstall...

Perhaps I should edit the 'script' output?

I'll try those....

/Users/andre/Speeltuin/Rust/projects/guessing_game/target/debug/build/libc-199c8bfe631320b5/build-script-build
cargo:rerun-if-changed=build.rs

thread 'main' panicked at /Users/andre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.172/build.rs:152:38:
Failed to get rustc version: missing RUSTC env
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
andre@MacBook-Air-van-Andre guessing_game % rustc -vV
rustc 1.86.0 (05f9846f8 2025-03-31)
binary: rustc
commit-hash: 05f9846f893b09a1be1fc8560e33fc3c815cfecb
commit-date: 2025-03-31
host: aarch64-apple-darwin
release: 1.86.0
LLVM version: 19.1.7

Weird.... I followed the install stuff...

Note that you have not described your actual issue in much detail. Have you initially been able to compile and run (your) Rust code, e.g. "cargo new my_test; cd my_test; cargo run"?. What exactly have you added to the dependencies? Are you running a virus checker that might instantly delete files?

Script started on Mon Apr 21 13:33:39 2025
Restored session: Sun Apr 20 19:11:43 CEST 2025

projects % cargo new my_test; cd my_test; cargo run

Creating binary (application) my_test package

note: see more Cargo.toml keys and their definitions at The Manifest Format - The Cargo Book

Compiling my_test v0.1.0 (/Users/andre/Speeltuin/Rust/projects/my_test)

Building [ ] 0/1: my_test(bin)
Finished dev profile [unoptimized + debuginfo] target(s) in 4.05s

Running target/debug/my_test

Hello, world!

cd my_test
my_test % vi Cargo.toml

[packagea]
name = "my_test"
version = "0.1.0"
edition = "2024"

[dependencies]
rand-"0.9.0"

"Cargo.toml" 7L, 91B written

my_test % cargo run

Updating crates.io index
Locking 17 packages to latest Rust 1.86.0 compatible versions
Adding bitflags v2.9.0
Adding cfg-if v1.0.0
Adding getrandom v0.3.2
Adding libc v0.2.172
Adding ppv-lite86 v0.2.21
Adding proc-macro2 v1.0.95
Adding quote v1.0.40
Adding r-efi v5.2.0
Adding rand v0.9.1
Adding rand_chacha v0.9.0
Adding rand_core v0.9.3
Adding syn v2.0.100
Adding unicode-ident v1.0.18
Adding wasi v0.14.2+wasi-0.2.4
Adding wit-bindgen-rt v0.39.0
Adding zerocopy v0.8.24
Adding zerocopy-derive v0.8.24
Compiling libc v0.2.172
Compiling zerocopy v0.8.24
Compiling getrandom v0.3.2
Compiling cfg-if v1.0.0
Building [ ] 0/15: cfg-if, zerocopy(build.rs), getrandom(build.rs), libc(build.rs)
Building [> ] 1/15: cfg-if, zerocopy(build.rs), getrandom(build.rs), libc(build)
Building [==> ] 2/15: cfg-if, getrandom(build.rs), libc(build), zerocopy(build)
Building [====> ] 3/15: cfg-if, libc(build), zerocopy(build), getrandom(build)
error: failed to run custom build command for libc v0.2.172
Caused by:

process didn't exit successfully: /Users/andre/Speeltuin/Rust/projects/my_test/target/debug/build/libc-199c8bfe631320b5/build-script-build (exit status: 101)

--- stdout

cargo:rerun-if-changed=build.rs

--- stderr

thread 'main' panicked at /Users/andre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.172/build.rs:173:9:

failed to run rustc:

note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

warning: build failed, waiting for other jobs to finish...
Building [======> ] 4/15: cfg-if, zerocopy(build), getrandom(build)
Building [========> ] 5/15: zerocopy(build), getrandom(build)
Building [==========> ] 6/15: zerocopy(build)

error: failed to run custom build command for zerocopy v0.8.24

Caused by:

process didn't exit successfully: /Users/andre/Speeltuin/Rust/projects/my_test/target/debug/build/zerocopy-93d86abaa41e2c0a/build-script-build (exit status: 101)

--- stdout

cargo:rerun-if-changed=build.rs

cargo:rerun-if-changed=Cargo.toml

--- stderr

thread 'main' panicked at /Users/andre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/zerocopy-0.8.24/build.rs:221:9:
rustc failed with status: signal: 9 (SIGKILL)

rustc output:

note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

my_test %

Saving session...

...saving history...truncating history files...

...completed.

Script done on Mon Apr 21 13:36:45 2025

That is invalid syntax (or is it only copy paste issue for this forum?)

Correct is

[dependencies]
rand = "0.9.0"

Instead manually editing Cargo.toml file, you can do it starting from the default file with Cargo tool, like "cargo add rand".

1 Like

But Google tells that the actual issue seems to be an anti virus software, see

1 Like

Grpmph. It looks like 'Deepguard'is causing trouble...
Trying to fix that