Trying to run Hello World in Windows 8.1


#1

Newby question: I installed Rust on Windows 8.1. But I’m new at Powershell and can’t get my Hello World to compile:

(1) Windows added a .txt extension onto my main.rs file. I can’t find an option to remove the .txt in Windows Explorer, and in Powershell, get “Rename-Item : Access to the path is denied” – even after I changed the folder permissions.

(2) Also, I can’t run rustc at all. I get, “The term ‘rustc’ is not recognized as the name of a cmdlet, function, …” I’ve set the Location to my project directory; do I also need to put something into a pathname?

Any suggestions for getting over these problems?


#2

For the first one, how did you create main.rs in the first place? An editor of some kind? In what directory did you put all this?

You need to set this to where rustc was installed, not the project itself. I’m not sure where that is by default though… @retep998?


#3
  1. in windows explorer, make sure ‘File name extension’ is checked in ribbon tab ‘view’.
    So you can remove .txt from the filename.

  2. Rust MSI installer don’t automaticly put rustc & cargo bin folder to PATH variable.
    When you install rust, make sure to select ‘advance’ and check options for something like ‘add rust folder to PATH’

~~ I use windows 8.1


#4

You can toggle visible file name extensions in Windows explorer like this


In order to invoke rustc or cargo from your terminal you need to add their location to your PATH. If you don’t want to use the option in the installer to set your global PATH, then you can still set it temporarily for a given terminal. For example, if I installed Rust to C:\rust64-1.1.0, if I’m using cmd I would do SET PATH=%PATH%;C:\Rust64-1.1.0\bin; if I was using Powershell I would do $env:Path += ";C:\Rust64-1.1.0\bin".


#5

Also, when you have added everything you need to the PATH, you might want to use the cmd instead of the Powershell.

The Powershell is a mighty tool that’s hard to understand, learning to use it might take you few weeks.


#6

Thanks, the four replies above are very helpful and clearly will solve the problem.