rust-lang / rust-mode

Emacs configuration for Rust
Apache License 2.0
1.09k stars 176 forks source link

`cargo run` could not determine which binary to run. Use the `--bin` option to specify a binary, or the `default-run` manifest key. #460

Open geometryolife opened 1 year ago

geometryolife commented 1 year ago

When I use C-c C-c C-r to run the currently open program, this error will be reported, how can I fix it?

image

brotzeit commented 1 year ago

You can either remove one of your binaries from your Cargo.toml or you can try adding the bin you want to run to rust-cargo-default-arguments. Why do you need two binaries ?

geometryolife commented 1 year ago

This is actually a learning repository with many small projects created using cargo new, I want to run this small project after I open a small project, not run all the projects. If I don't use lsp it seems to work for my purpose, when I enable lsp it gives this error.

brotzeit commented 1 year ago

It should be the same result when you run cargo run in your shell.

geometryolife commented 1 year ago

It should be the same result when you run cargo run in your shell.

image

If I run it in the shell, I get the correct result and no errors. I think it's because rust-mode can't locate the nearest project's Cargo.tmol file when running the cargo run command.

Afoxcute commented 1 month ago

do you still need help?