Rustup update is looking in the wrong directory

I've installed rust via the 64bi rustup-init.exe. After a successful install, I changed the environment variable "path" to point to a C:\Program Files.cargo\bin and move the originally installed .cargo directory to this new location. After rebooting Windows 11, I fire up a command prompt and run 'rustup --version'. It all works as expected. However, when I type 'rustup update' I get the following error:

error: rustup is not installed at 'C:\Users\br15.cargo'

This was the original installation directory. I looks like rustup is getting the location of the rust binaries from an external source rather than using its execution directory.

Keith

Some web search suggests that you might need to change (or set) the CARGO_HOME environment variable to the new location of the .cargo directory.

Thanks for the reply. I added an environment variable for CARGO_HOME pointing to "C:\Program Files.cargo\bin". When I run rustup, I get the following output.

C:\Program Files.cargo\bin>rustup update
info: syncing channel updates for 'stable-x86_64-pc-windows-msvc'
error: rustup is not installed at 'C:\Program Files.cargo\bin'

rustup says it can't find itself in the directory from which it is running?

Keith

Point $CARGO_HOME to C:\Program Files.cargo (without the \bin). The \bin directory is the part of your cargo home where the executables are stored.

You should add C:\Program Files.cargo\bin to your $PATH to make the executables accessible in your terminal.

Thanks Jofas, that did the trick. I do think that the error message is misleading though.

Cheers
Keith

You're welcome.

I agree, it's a very generic error message. A hint that the $CARGO_HOME environment variable may not be set or pointing to the wrong directory would have been helpful. You could open an issue in the rustup repository.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.