I try to create a project with cargo, and then execute cargo run, the following error occurs
hello_cargo git:(master) ✗ cargo run
Compiling hello_cargo v0.1.0 (/Users/veath/information/learn-rust/hello_cargo)
Finished dev [unoptimized + debuginfo] target(s) in 0.66s
Running `target/debug/hello_cargo`
error: could not execute process `target/debug/hello_cargo` (never executed)
Caused by:
No such file or directory (os error 2)
You shouldn't be mixing cargo commands with raw invocations of rustc. If you want a Cargo project, then use cargo build and cargo run. If you don't want a Cargo project, then you'll need to execute the resulting binary directly, eg. ./main. (Not recommended.)
Yes, I didn’t mix them. The hello_world project used rustc. I re-created another project hello_cargo with cargo new, and then run cargo build. It seems that no binary files were generated.
➜ hello_cargo git:(master) ✗ cargo build
Compiling hello_cargo v0.1.0 (/Users/veath/information/learn-rust/hello_cargo)
Finished dev [unoptimized + debuginfo] target(s) in 0.53s
➜ hello_cargo git:(master) ✗ cargo run
Compiling hello_cargo v0.1.0 (/Users/veath/information/learn-rust/hello_cargo)
Finished dev [unoptimized + debuginfo] target(s) in 0.20s
Running `target/debug/hello_cargo`
error: could not execute process `target/debug/hello_cargo` (never executed)
Caused by:
No such file or directory (os error 2)
That commandline looks correct. Maybe check if the linker is correctly invoked? Something like RUSTFLAGS="-Clink-arg=--bogus-args" cargo build should work. It should return an error. Could you post the full error?