kitamstudios / rust-analyzer.vs

Rust language support for Visual Studio 2022
https://marketplace.visualstudio.com/items?itemName=kitamstudios.RustAnalyzer
Other
138 stars 10 forks source link

Prerequisite check(s) failed (cargo.exe) #16

Closed Puncia closed 1 year ago

Puncia commented 1 year ago

image

I am getting this message whenever I open a project initialized with cargo init or when I go to Tools -> Options -> rust-analyzer.vs. I uninstalled and installed multiple times Rust using rustup-init.exe from the official website, and I am able to run cargo correctly from the command line, initialize new projects and access the local docs. All files are present in the home directory:

image

Is there any log files I can check from the extension? I'm not sure what is going on.

parthopdas commented 1 year ago

@Puncia thank you for reporting this. this comes up when cargo.exe is not in path.

please can you tell me the following?

  1. open cmd.exe, run where.exe cargo.exe -> what do you see?
  2. does your path variable have the c:\users\pnc\.cargo\bin?

also while you are at it, can you close VS and restart again?

Puncia commented 1 year ago

It looks like cargo.exe is not found from cmd.exe, but works instead using powershell. After some further investigation I found out that my PATH is over 2047 characters long, which apparently causes problems.. As a workaround I manually edited this registry entry: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PATH which allowed me to override the character limit and put c:\users\pnc\.cargo\bin manually, but that's beyond the scope of this issue I guess.

I've been always using powershell lately so thank you for bringing up cmd.exe as well. I am now able to run the extension and debug Rust projects without issues. Thanks.

also while you are at it, can you close VS and restart again?

Side note, but when the error message is displayed, either clicking OK or closing the window visual studio restarts again and, if we were previously inside a Rust project, the error would automatically show again because it opens the project after restart, making visual studio restart again after closing the error and so on creating a loop where it's only possible to exit using ALT+F4 on visual studio.

parthopdas commented 1 year ago

i'll push in a fix to first search in the $env:USERPROFILE\.cargo\bin and then fall back to a path search.

also let me know how you'd prefer to have the side note issue fixed? thing is if i do not block the user, they will proceed to have a really confusing experience where some things work and others don't.

Puncia commented 1 year ago

i'll push in a fix to first search in the $env:USERPROFILE\.cargo\bin and then fall back to a path search.

Sounds good!

also let me know how you'd prefer to have the side note issue fixed? thing is if i do not block the user, they will proceed to have a really confusing experience where some things work and others don't.

I'm not sure, because as per this message only by pressing OK the instructions will open, but in reality also closing the window does it, and that would be a way to avoid the "loop". But it will also create problems for inexperienced users or for those that do not pay exact attention to the message.

Perhaps show the message every time it's opportune (when opening a rust project or viewing the settings), but also offer a way out without restarting, notifying the user their config will be broken up until visual studio will be restarted again.

parthopdas commented 1 year ago

looking in $env:USERPROFILE.cargo\bin for cargo.exe first.