Skip to content

Commit c407a0a

Browse files
committed
Make Windows instructions correct and clearer
Fixes #196.
1 parent b12ae8d commit c407a0a

File tree

3 files changed

+49
-30
lines changed

3 files changed

+49
-30
lines changed

src/ch01-01-installation.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,24 @@ Rust is installed now. Great!
2929

3030
### Installing on Windows
3131

32-
If you're on Windows, please download the appropriate [installer][install-page].
32+
If you're on Windows, please go to [rustup.rs](https://rustup.rs/) and follow
33+
the instructions to download rustup-init.exe. Run that and follow the rest of
34+
the instructions.
3335

34-
[install-page]: https://www.rust-lang.org/install.html
36+
The rest of the Windows-specific commands in the book will assume that you are
37+
using `cmd` as your shell. If you use a different shell, you may be able to run
38+
the same commands that Linux and Mac users do. If neither work, consult the
39+
documentation for the shell you are using.
3540

3641
### Uninstalling
3742

38-
Uninstalling Rust is as easy as installing it. On Linux or Mac, just run
43+
Uninstalling Rust is as easy as installing it. From your shell, run
3944
the uninstall script:
4045

4146
```bash
4247
$ rustup self uninstall
4348
```
4449

45-
If you used the Windows installer, you can re-run the `.msi` and it will give
46-
you an uninstall option.
47-
4850
### Troubleshooting
4951

5052
If you've got Rust installed, you can open up a shell, and type this:
@@ -64,12 +66,11 @@ If you see this, Rust has been installed successfully!
6466
Congrats!
6567

6668
If you don't and you're on Windows, check that Rust is in your `%PATH%` system
67-
variable. If it isn't, run the installer again, select "Change" on the "Change,
68-
repair, or remove installation" page and ensure "Add to PATH" is checked.
69+
variable.
6970

7071
If it still isn't working, there are a number of places where you can get help.
7172
The easiest is [the #rust IRC channel on irc.mozilla.org][irc], which you can
72-
access through [Mibbit][mibbit]. Click that link, and you'll be chatting with
73+
access through [Mibbit][mibbit]. Go to that address, and you'll be chatting with
7374
other Rustaceans (a silly nickname we call ourselves) who can help you out.
7475
Other great resources include [the user’s forum][users] and [Stack
7576
Overflow][stackoverflow].
@@ -82,6 +83,5 @@ Overflow][stackoverflow].
8283
### Local documentation
8384

8485
The installer also includes a copy of the documentation locally, so you can
85-
read it offline. On Linux or Mac, run `rustup doc` to open the local
86-
documentation in your browser. On Windows, the documentation is in a
87-
`share/doc` directory inside the directory where Rust was installed.
86+
read it offline. Run `rustup doc` to open the local documentation in your
87+
browser.

src/ch01-02-hello-world.md

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,23 @@ lives, but for this book, we'd suggest making a *projects* directory in your
1717
home directory and keeping all your projects there. Open a terminal and enter
1818
the following commands to make a directory for this particular project:
1919

20+
Linux and Mac:
21+
2022
```bash
2123
$ mkdir ~/projects
2224
$ cd ~/projects
2325
$ mkdir hello_world
2426
$ cd hello_world
2527
```
2628

27-
> Note: If you’re on Windows and not using PowerShell, the `~` that represents
28-
> your home directory may not work.
29-
> Consult the documentation for your shell for more details.
29+
Windows:
30+
31+
```bash
32+
$ mkdir %USERPROFILE%\projects
33+
$ cd %USERPROFILE%\projects
34+
$ mkdir hello_world
35+
$ cd hello_world
36+
```
3037

3138
### Writing and Running a Rust Program
3239

@@ -52,10 +59,10 @@ $ ./main
5259
Hello, world!
5360
```
5461

55-
On Windows, just replace `main` with `main.exe`. Regardless of your operating
56-
system, you should see the string `Hello, world!` print to the terminal. If you
57-
did, then congratulations! You've officially written a Rust program. That makes
58-
you a Rust programmer! Welcome.
62+
On Windows, just replace `./main` with `.\main.exe`. Regardless of your
63+
operating system, you should see the string `Hello, world!` print to the
64+
terminal. If you did, then congratulations! You've officially written a Rust
65+
program. That makes you a Rust programmer! Welcome.
5966

6067
### Anatomy of a Rust Program
6168

@@ -129,16 +136,17 @@ main main.rs
129136
On Windows, you'd enter:
130137

131138
```bash
132-
$ dir
133-
main.exe main.rs
139+
$ dir /B # the /B option says to only show the file names
140+
main.exe
141+
main.rs
134142
```
135143

136144
This shows we have two files: the source code, with the `.rs` extension, and the
137145
executable (`main.exe` on Windows, `main` everywhere else). All that's left to
138146
do from here is run the `main` or `main.exe` file, like this:
139147

140148
```bash
141-
$ ./main # or main.exe on Windows
149+
$ ./main # or .\main.exe on Windows
142150
```
143151

144152
If *main.rs* were your "Hello, world!" program, this would print `Hello,
@@ -193,11 +201,19 @@ Let's create a new project using Cargo and look at how it differs from our
193201
project in `hello_world`. Go back to your projects directory (or wherever you
194202
decided to put your code):
195203

204+
Linux and Mac:
205+
196206
```bash
197207
$ cd ~/projects
198208
```
199209

200-
And then run:
210+
Windows:
211+
212+
```bash
213+
$ cd %USERPROFILE%\projects
214+
```
215+
216+
And then on any operating system run:
201217

202218
```bash
203219
$ cargo new hello_cargo --bin
@@ -213,10 +229,10 @@ directory of the same name that we can then go into.
213229
If we list the files in the `hello_cargo` directory, we can see that Cargo has
214230
generated two files and one directory for us: a `Cargo.toml` and a *src*
215231
directory with a *main.rs* file inside. It has also initialized a new `git`
216-
repository in the `hello_cargo` directory for us; you can change this to use a
217-
different version control system, or no version control system, by using the
218-
`--vcs` flag.
219-
232+
repository in the `hello_cargo` directory for us, along with a `.gitignore`
233+
file; you can change this to use a different version control system, or no
234+
version control system, by using the `--vcs` flag.
235+
dir
220236
Open up `Cargo.toml` in your text editor of choice. It should look something
221237
like this:
222238

@@ -287,10 +303,10 @@ $ cargo build
287303
```
288304

289305
This should have created an executable file in `target/debug/hello_cargo` (or
290-
`target/debug/hello_cargo.exe` on Windows), which you can run with this command:
306+
`target\debug\hello_cargo.exe` on Windows), which you can run with this command:
291307

292308
```bash
293-
$ ./target/debug/hello_cargo # or ./target/debug/hello_cargo.exe on Windows
309+
$ ./target/debug/hello_cargo # or .\target\debug\hello_cargo.exe on Windows
294310
Hello, world!
295311
```
296312

@@ -340,6 +356,10 @@ So a few more differences we've now seen:
340356
4. Instead of the result of the build being put in the same directory as our
341357
code, Cargo will put it in the `target/debug` directory.
342358

359+
The other advantage of using Cargo is that the commands are the same no matter
360+
what operating system you're on, so at this point we will no longer be
361+
providing specific instructions for Linux and Mac versus Windows.
362+
343363
### Building for Release
344364

345365
When your project is finally ready for release, you can use `cargo build

src/ch02-00-guessing-game-tutorial.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ Let’s set up a new project. Go to your projects directory from the previous
2121
chapter, and create a new project using Cargo, like so:
2222

2323
```bash
24-
$ cd ~/projects
2524
$ cargo new guessing_game --bin
2625
$ cd guessing_game
2726
```

0 commit comments

Comments
 (0)