I'm following the guide in the docs. I have installed Visual Studio Intaller and downloaded the rustup-init.exe.
When I launch the exe I get the following output:
The Cargo home directory is located at:
C:\Users\user\.cargo\bin
This can be modified with the CARGO_HOME environment variable.
The cargo, rustc, rustup and other commands will be added to
Cargo's bin directory, located at:
C:\Users\user\.cargo\bin\bin
The Cargo home directory is located at:
C:\Users\user\.cargo\bin
This can be modified with the CARGO_HOME environment variable.
The cargo, rustc, rustup and other commands will be added to
Cargo's bin directory, located at:
C:\Users\user\.cargo\bin\bin
This path will then be added to your PATH environment variable by
modifying the HKEY_CURRENT_USER/Environment/PATH registry key.
You can uninstall at any time with rustup self uninstall and
these changes will be reverted.
But no user/.cargo folder is created and when I try to rustc --version I receive a The term 'rustc' is not recognized as the name of a cmdlet, function, script file, or operable program. error.
I can succesfully install rust on WSL2 in the same machine, and I have added C:\Users\user\.cargo\bin and C:\Users\user\.cargo\bin\bin to the Path variable of user
I tried with no success.
The installer didn't modify the PATH env var and I did manually and restarted once more time.
I think the problem here is that the installer doesn't create the .cargo directory either... when I install rust on WSL2 it is generated and it works properly
Do you have "invisible" directories visible on your machine? It seems unlikely that rustup-init is both failing to create the directory and to report an error resulting from it failing to do so. It's slightly more plausible that the directory is being treated as invisible.
How are you running rustup-init? If you're running it in a WSL shell, this will likely cause some very unexpected behavior. (Run it either from cmd, pwsh, or just clicking it from the non-WSL GUI.)
You can also try running from an elevated command prompt context to see if that has any impact. It's supposed to be unnecessary, but running in the "visual studio configured shell" might also be helpful. (I don't know how to actually launch them normally; they were auto discovered as Windows Terminal configurations for me.)
If you're an antivirus, see if it's logged anything w.r.t. the .cargo directory and/or rustup-init; the behavior of rustup-init (dropping a bunch of .exes on the filesystem) is commonly flagged as potentially malicious.
Thank you I got it!
I'm on windows and I was just clicking on the rust-init.exe file obtaining the result posted in the question.
I simply had to run the file from PowerShell as Administrator and now the installation works.
Yes this does seem to be a problem with console output rather than the installer but I've not been able to track down the issue (most because I can only sometimes reproduce it). This may be fixed in the next version of rustup (due to updated dependencies) but I'm not sure.
I would not really recommend running rustup-init as admin. It's designed to run with the default permissions of the current user.