.cargo\bin PATH issue on Windows (absolute beginner)

First of all apologies if this was asked. I looked it up (here and elsewhere) before asking. Most of the answers are given for *nix systems.

I'm trying to learn Rust, on Windows. I installed it and confirmed it is where it should be:

C:\Users\myname\.cargo\bin> rustup --version
rustup 1.21.1 (7832b2ebe 2019-12-20) 

I checked environmental variables for both system and my account. Both have C:\Users\myname\.cargo\bin set in Path, among other locations.

If I try to use cargo in CMD.exe in any directory other than in the one above, it is not recognized untill I cd to .cargo\bin directory. I'm bit confused by this. Any idea what I should do to make this command visible from anywhere?

.cargo\bin is cargo's private directory, and you're not supposed to cd there, ever.

cargo command is supposed to work in every directory, thanks to PATH environmental variable. By default, rustup installation sets this up for you.

  • Try closing the terminal and re-opening it. If that doesn't help reboot.

  • If rustup hasn't set up PATH, either run rustup installation again, or try adding it manually.

1 Like

Hi kornel,

Thank you for your reply.

Noted regarding the bin directory.

I actually did try reopening the CMD.exe, restarting, and setting up the Path in both Windows system and user account environmental variables settings). This was mentioned elsewhere as part of troubleshooting process.

Running the installer again simply states that rust is installed (congrats message).

I also tried uninstalling via rustup self uninstall (I found this somewhere else online) and then repeating the installation and the troubleshooting steps but I'm still experiencing the same problem.

I'm all out of ideas. Not off to a good start I must say. All these issues without even actually doing anything makes me wonder how it would look like actually doing something in it...

I can't tell if this is Discourse's formatting or an issue with your PATH, but the path in your posts displays without a backslash between "myname" and ".cargo". Those should be two separate directories: C:\Users\myname\.cargo\bin.

It was a formatting issue.

Just out of curiosity, what happens when you run echo %PATH% in a shell? Does it print out the expected path with an entry to your C:\Users\myname\.cargo\.bin?

In the past I had problems where I was updating the path for the administrator (I needed to run something as admin) and not for my current user.

This is definitely not a normal experience! I've installed rust on several Windows computers at work and it all Just Worked. If rustup is actually adding ~\.cargo\bin to the PATH variable then something else may be going on. If you are in an enterprise environment the domain policy may be playing with environment variables.

If all else fails, I'd suggest creating an issue on the rust-lang/rustup repository's issue tracker so they can help solve your problem and make sure it doesn't happen to the next guy.

Hi rpjohnst, mbrubeck, Michael-F-Bryan,

Thank you all for your replies.

rpjohnst, That was probably a typo from my end.

I just want to let you all know that after going through additional three uninstall/install cycles, I am now able to invoke cargo from anywhere in CMD.exe. I'm not sure what happened but at least it works now. I also tried Atom and VSC and the command runs fine in them too (via appropriate packages/extensions).

I'll take it with me from this thread not to cd into bin folder as kornel noted.

Thank you all one more time.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.