-
Notifications
You must be signed in to change notification settings - Fork 1.7k
#![no_std]
can't find crate for test
in vs code
#3801
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I don't know why they're needed, but those settings are spelled |
Thank you @lnicola, that worked! .vscode\settings.json file:
|
The current configuration seems to have changed, can you still work? |
{
"rust-analyzer.checkOnSave.allTargets": false,
"rust-analyzer.checkOnSave.extraArgs": [
"--target",
"thumbv7m-none-eabi"
]
} |
Hello, I'm encountering this issue at Vrixyz/button@b1707a9 I tried all your options for the .vscode/settings with no success for a full working solution. Auto-completion works if I restart VSCode. Source from https://github.com/rust-embedded/discovery was working correctly, so I did setup my source to use a workspace to match its structure as much as possible, It worked for a moment 🤷 but then the error came back. PS: I'm on macOS Catalina |
Thanks for the update @lnicola. Yes it broke but your new settings work, cheers! |
Unfortunately I'm on Windows so I can't say why it's not working for you on a Mac. Make sure you use the new settings @inicola posted and not my old settings. The settings can be scoped to your Workspace or User. Works for both. Also make sure you have run "rustup update" recently as there has been a new compiler release a few days ago. |
Thanks ❤️ , |
I appear to be running in this bug... I'm working in a workspace. I'm using a custom target. Here's my {
"rust-analyzer.checkOnSave.allTargets": false,
"rust-analyzer.checkOnSave.overrideCommand": ["cross"],
"rust-analyzer.checkOnSave.extraArgs": [
"--target",
"x86_64-unknown-custom"
],
} I also tried without the overrideCommand flag. Any suggestions? |
I haven't had to use overrideCommand but for one project I had to change "check" to "xcheck" like so: perhaps you could try something like |
All of the above didn't work out for me. Any ideas, guys? |
This is either a regression or something else but still seems to be a problem, could anyone reopen it?: |
@brainstorm you're using the wrong preferences, see the comments above like #3801 (comment). |
Aah, sweet, thanks @lnicola, works now! :) |
Another gotcha I have come across is opening vs code in the wrong folder. For example, if you open vs code in a folder without a cargo.toml file (maybe your toml file is in a sub folder of this one) then rust-analyzer will not read your settings.json file. A quick sanity check would be to run "cargo check" on the folder you open vs code in and see if it runs ok. |
It seems to not be working for me. {
"rust-analyzer.checkOnSave.allTargets": false,
"rust-analyzer.checkOnSave.extraArgs": [
"--target",
"thumbv7em-none-eabihf"
]
} still results in the test error in vscode. |
@dialtone, Do you have the right target installed?
Another thing to check is your general cargo setup (Cargo.toml, .cargo/config file, workspaces etc). Try another |
Yeah, code compiles and runs on the embedded device when I |
I cloned your repo and got the error message to go away by adding a .vscode/settings.json file in your project root with
VS Code needed a restart for rust-analyzer to pick it up. So the file structure is (I've included the important files):
You were missing the settings.json file. |
Well, that file was simply not checked in, but it just doesn't make the errors go away for me for some reason. Happy to do whatever you want to debug this. |
I think it would be appropriate to check that file into your repo especially since it would be nice to have a known working repo linked in this thread. |
done |
Just to be clear though, the repository still doesn't work for me, even with the file checked in and having opened the project from the right directory. |
Thanks. Your repo works (without showing the error message) for me on both linux and windows with a fresh checkout. Other than a strangely named |
Well done all of the above and checked the global settings config and can't spot anything obviously wrong so I'll just keep it broken. below is my global vscode settings file.
|
@dialtone are you using vscode-rust or rust-analyzer? You seem to have settings for the former, but this is the issue tracker for the latter. You should uninstall vscode-rust if you have it, and install rust-analyzer. |
I don't have vscode-rust installed. Some of the settings up there, I can remove them all except the defaultFormatter without which rust-analyzer does no formatting of the code. The end result doesn't change. |
Do the settings work? If they don't apply, they should have a gray-ish color. You shouldn't need to set the fornatter like that. And I guess vscode-rust is called differently now? |
Looks like that may have done it then. Basically the "official" rust extension on VSCode called "rust-lang.rust" should be removed in favor of "matklad.rust-analyzer"? |
If you want to use rust-analyzer, yes, don't install both. Some of us prefer it to the official one (and it might replace it in the future), but YMMV. |
ok, sounds like the issue is now resolved, at least there's a documentation trail for this here now :) |
We really need to put this in users' faces. For some reason there is a lot
of confusion around this topic.
…On Thu, Oct 15, 2020, 12:18 PM Laurențiu Nicola ***@***.***> wrote:
If you want to use rust-analyzer, yes, don't install both. Some of us
prefer it to the official one (and it might replace it in the future), but
YMMV.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#3801 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABBACRBRGODMH2GLIKTPGVLSK4OGPANCNFSM4LYTRETQ>
.
|
Well, it's in the manual: https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/manual.adoc#vs-code. |
I just ran into this today. The only problem is that I have multiple crates in my project, and that one of them targets |
I am getting this error again. Is anyone else? I didn't use to get it with "rust-analyzer.cargo.target": "thumbv7em-none-eabihf",
"rust-analyzer.checkOnSave.allTargets": false,
"rust-analyzer.checkOnSave.overrideCommand": [
"cargo",
"clippy",
"--message-format=json",
"--bins",
"--all-features",
"--target",
"thumbv7em-none-eabihf",
], |
I was having the same issue and after a little poking around I don't think this is an issue with the rust-analyzer extension, but actually the |
@andrewgazelka The problem in your config is that you override the command arguments and add I tried this today on a new project, and if you specify the target in [build]
target = "avr-specs/avr-atmega328p.json" Then all you need in your {
"rust-analyzer.checkOnSave.allTargets": false,
} |
You need to specify the target platform or you get some errors. rust-lang/rust-analyzer#3801
Looks like these keys keep changing. In the latest rust analyzer, it is this one for me {
"rust-analyzer.cargo.target": "x86_64-unknown-none",
"rust-analyzer.check.allTargets": false,
"rust-analyzer.check.extraArgs": [
"--target",
"x86_64-unknown-none"
]
} |
None of these worked for me. I still have the same errors. |
same to me, sad . |
Please reopen issue |
I create dir and file |
Yes, I also did this. It did not work. |
Not working for me either. Config: {
"rust-analyzer.cargo.target": "x86_64-unknown-none",
"rust-analyzer.check.allTargets": false,
"rust-analyzer.check.extraArgs": ["--target", "x86_64-unknown-none"]
} |
Issue is still there. I got the above error with the following workspace settings: {
"rust-analyzer.cargo.target": "thumbv6m-none-eabi",
"rust-analyzer.cargo-watch.allTargets": false,
"rust-analyzer.cargo-watch.arguments": [
"--target",
"thumbv6m-none-eabi"
],
"rust-analyzer.checkOnSave.extraArgs": [
"--target",
"thumbv6m-none-eabi"
]
} |
I'm noticing while developing for the stm32 "rust-analyzer.check.allTargets": false,
"rust-analyzer.check.extraArgs": [
"--target",
"thumbv7em-none-eabihf"
], But it also seems to have a side effect of preventing errors or warnings showing up of code under examples If I set check.allTargets to true then it does check code under examples, but flags that missing test crate error |
Weirdly this issue occurred for me when simply copying a directory with an existing sample project, no issue in the original one but
Generally, when you try this or any other solution in |
Hi,
Same issue as #3297 but the solution there (for vim) does not seem to work for vs code on windows unfortunately.
Here is my setup:
.cargo\config file:
.vscode\settings.json file:
src\main.rs file:
rust-analyzer version: 0.2.108
vs code version: 1.43.2
operating system: Windows 10
rustc 1.42.0 (b8cedc004 2020-03-09) stable
The text was updated successfully, but these errors were encountered: