vscode-rust icon indicating copy to clipboard operation
vscode-rust copied to clipboard

Cargo.toml is incorrectly all underlined when build fails

Open canadaduane opened this issue 4 years ago • 17 comments

I believe the cargo build is failing on one particular package, and vscode is unable to show that the error belongs to a single line?

image

This was very confusing, as I thought at first that I had misunderstood how to write TOML.

I believe the cause of the failed build is that I'm using a particular back-dated version of nightly, and I can't seem to communicate this fact to rls-vscode. As a result, one of the crates fails.

canadaduane avatar Jan 17 '20 17:01 canadaduane

I'm having the same issue, with the same build failed: could not compile - but the module cited changes over time. As per the OP, the error is incorrect. The program builds and runs correctly - there seems to be a problem with RLS.

I first detected this with an amethyst game.

I've tried this with several different programs and get the same outcome. RLS detects a single error in Cargo.toml, program builds correctly.

Updating RLS in VSCode or reinstalling RLS and/or VSCode doesn't help.

ToferC avatar Mar 29 '20 01:03 ToferC

I am also experiencing this. The code compiles fine with cargo build and it runs fine aswell but in vscode it doesn't show errors since the cargo.toml file is in error state

lemonxah avatar Mar 30 '20 09:03 lemonxah

I am experiencing this as well. Not sure if it matters, but mine complains of not being able to build a custom build command from rocket-contrib.

error: failed to run custom build command for `rocket_codegen v0.4.3`

kylegalloway avatar Apr 17 '20 19:04 kylegalloway

I also seem to be experiencing this. My error is the following:

could not compile `futures-macro`.
error: could not compile `tokio-macros`.

To learn more, run the command again with --verbose.
error: could not compile `async-trait`.

To learn more, run the command again with --verbose.

And still, it builds

isdelrey avatar Apr 18 '20 18:04 isdelrey

I am encountering this too when using a rust framework that builds the app in a custom way through its CLI (Tauri) and building with cargo makes the build fail. The result is that while I actually built successfully (through the framework's CLI build), the extension still marks my cargo.toml as "Build failed" and it just stops finding any other errors, becoming useless.

Plasmoxy avatar May 04 '20 21:05 Plasmoxy

Same is happening here with an embedded rust project. Here's the code in case you want to replicate: https://github.com/reneherrero/blue-pill-quickstart

reneherrero avatar Jun 06 '20 14:06 reneherrero

I’m curious if the solution here solves this problem. https://github.com/rust-lang/rls-vscode/issues/729#issuecomment-591350776

rubberduck203 avatar Jun 07 '20 09:06 rubberduck203

@rubberduck203 Does not. I have that settings file in my quickstart

reneherrero avatar Jun 07 '20 13:06 reneherrero

The workaround seems to be to close Cargo.toml and reopen it after a good build.

alanhkarp avatar Sep 28 '20 18:09 alanhkarp

I'm also experiencing the same issue. I can build and run the application correctly, but VS Code is reporting the following error in my Cargo.toml

failed to run custom build command for alignment v0.1.0 The following warnings were emitted during compilation:

Unfortunately it doesn't show any errors after the colon so I'm unsure what, if anything, needs to be fixed.. I do have a custom build script in which I'm compiling proto's and running cmake.

Again, as stated above, everything builds and runs correctly, it's just VS Code (RLS) which seems to be having an issue.

wbuck avatar Sep 28 '20 20:09 wbuck

I'm seeing this too:

failed to run rustc to learn about target-specific information

Opening VS Code's terminal and running cargo build works fine.

nathan-osman avatar Dec 27 '20 00:12 nathan-osman

So, further update: in my case, the problem was caused by some bad flags that were being passed to rustc through RUSTFLAGS. Removing these made the error disappear.

nathan-osman avatar Dec 28 '20 20:12 nathan-osman

This might be a necro, but I fixed this by installing RustAnalyzer and disabling RLS. So that might be worth a try.

00alia00 avatar Mar 24 '21 00:03 00alia00

I'm using Rust Analyzer and disabled RLS a long time ago, so I don't think that's the problem.


Alan Karp

On Tue, Mar 23, 2021 at 5:37 PM Alia @.***> wrote:

This might be a necro, but I fixed this by installing RustAnalyzer and disabling RLS. So that might be worth a try.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rust-lang/vscode-rust/issues/730#issuecomment-805380740, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACFAT44LVB6HOUQ6AC7H2ILTFEX3RANCNFSM4KILX42Q .

alanhkarp avatar Mar 24 '21 00:03 alanhkarp

Please file any rust-analyzer issue on that repository instead and make sure you use its own extension instead of the option in this one.

lnicola avatar Mar 24 '21 04:03 lnicola

I am having the same problem

Xyndra avatar May 08 '22 09:05 Xyndra

@Xyndra you should try https://marketplace.visualstudio.com/items?itemName=matklad.rust-analyzer

lnicola avatar May 08 '22 11:05 lnicola