tools-setup.md 6.41 KB
Newer Older
Olivier Blanvillain's avatar
Olivier Blanvillain committed
1 2
# Tools Setup

Guillaume Martres's avatar
Guillaume Martres committed
3 4 5 6 7 8 9
## Note

We recommend using Linux or macOS for this course, we also support Windows but
typically people have more trouble getting everything working correctly on
Windows and it's harder for us to help them since we don't use Windows
ourselves.

Guillaume Martres's avatar
Guillaume Martres committed
10
**On Windows, if your username has spaces or special characters in it, the IDE might not
11 12
work properly. Please create a new user with a username containing only letters.**

13
# Step 1: Create an account on gitlab.epfl.ch
Olivier Blanvillain's avatar
Olivier Blanvillain committed
14

15
If you haven't already [log into gitlab](https://gitlab.epfl.ch/users/sign_in)
16
and fill in [this table](https://docs.google.com/spreadsheets/d/12KvfD_jN5AcApmWhCz7xZmln48fctQOa984RPWrqRkY/edit#gid=0) with your GASPAR and SCIPER number to initialize your GitLab repository for the course. Do this as soon as possible because it will take some time between the account creation and the lab submission system working for your account.
Olivier Blanvillain's avatar
Olivier Blanvillain committed
17

Guillaume Martres's avatar
Guillaume Martres committed
18
## Step 2: Installing the Java Development Kit (JDK) and sbt via coursier
Olivier Blanvillain's avatar
Olivier Blanvillain committed
19

Guillaume Martres's avatar
Guillaume Martres committed
20 21
We will use coursier to install the correct version of
Java as well as the sbt build tool:
Olivier Blanvillain's avatar
Olivier Blanvillain committed
22

23
### On Linux and macOS
Olivier Blanvillain's avatar
Olivier Blanvillain committed
24 25

```shell
26
curl -fLo cs https://git.io/coursier-cli-"$(uname | tr LD ld)"
27 28
```
```shell
Guillaume Martres's avatar
Guillaume Martres committed
29
chmod +x cs
30 31
```
```shell
Guillaume Martres's avatar
Guillaume Martres committed
32
./cs setup -y --jvm 8 --apps cs,sbt
Olivier Blanvillain's avatar
Olivier Blanvillain committed
33 34
```

35 36
Please reboot after this point.

Guillaume Martres's avatar
Guillaume Martres committed
37 38
### On Windows

39 40
Download and install both the [Visual C++ 2010 SP1 Redistributable
Package](https://www.microsoft.com/en-us/download/details.aspx?id=26999) and [Visual C++ 2015 Redistributable Update](https://www.microsoft.com/en-us/download/details.aspx?id=52685) (click
41
on "Download" then select "vcredist_x64.exe" and click "Next").
42 43 44

Open `cmd.exe` (and not powershell)

45 46 47 48 49 50 51 52 53 54
First, make sure that you are not in the `System32` directory, instead you
should be in `C:\Users\yourusername`. If you are in `System32` you will need to
change directory to your user directory every time you start a terminal by
running:
```shell
cd %USERPROFILE%
```

Now assuming that you're in the correct directory you can run:

Olivier Blanvillain's avatar
Olivier Blanvillain committed
55
```shell
Guillaume Martres's avatar
Guillaume Martres committed
56
bitsadmin /transfer cs-cli https://git.io/coursier-cli-windows-exe "%cd%\cs.exe"
57 58
```
```shell
Guillaume Martres's avatar
Guillaume Martres committed
59
.\cs setup -y --jvm 8 --apps cs,sbt
Olivier Blanvillain's avatar
Olivier Blanvillain committed
60 61
```

Guillaume Martres's avatar
Guillaume Martres committed
62
(This command might cause your anti-virus to misidentify cs.exe as a virus,
63 64
please override that, that might require temporarily turning off your anti-virus
during this setup).
Guillaume Martres's avatar
Guillaume Martres committed
65

66 67 68 69 70 71
If this command fails with `Error running powershell script`, use the following
alternative instructions (if the command didn't fail, continue to the next
step):

1. Run `.\cs setup --jvm 8 --apps cs,sbt`, at every question answer "n" and
   press Enter.
Guillaume Martres's avatar
Guillaume Martres committed
72
2. The last question should look like "Should we add `C:\...\bin` to your PATH?",
Guillaume Martres's avatar
Guillaume Martres committed
73 74
   please copy the `C:\...\bin` part here.
3. Edit the Path environment variable and paste the path you just copied to it, see
75
   https://www.architectryan.com/2018/08/31/how-to-change-environment-variables-on-windows-10/
Guillaume Martres's avatar
Guillaume Martres committed
76 77
   and make sure the path you're adding is the first entry in the Path environment
   variable.
78
4. Start a **new** cmd.exe and continue with the rest of the instructions
79

80 81 82
**In case of errors please ask on Discord or Gitlab issues for help, but don't
try to run commands as Administrator as this will likely cause further issues!**

83 84
Please close this terminal and open a new one after this point.

Guillaume Martres's avatar
Guillaume Martres committed
85
## Step 5: Installing git
Olivier Blanvillain's avatar
Olivier Blanvillain committed
86

Guillaume Martres's avatar
Guillaume Martres committed
87
git is a version control system.
Olivier Blanvillain's avatar
Olivier Blanvillain committed
88

89
### On Ubuntu and Debian
Olivier Blanvillain's avatar
Olivier Blanvillain committed
90 91

```shell
Guillaume Martres's avatar
Guillaume Martres committed
92
sudo apt update && sudo apt install git
Olivier Blanvillain's avatar
Olivier Blanvillain committed
93 94 95 96
```

### On macOS

97 98 99 100 101 102 103 104
First, install the Homebrew package manager:

```shell
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```

Use Homebrew to install git:

Guillaume Martres's avatar
Guillaume Martres committed
105 106
```shell
brew install git
Olivier Blanvillain's avatar
Olivier Blanvillain committed
107 108 109 110
```

### On Windows

Guillaume Martres's avatar
Guillaume Martres committed
111
Download and install git from [https://git-scm.com/downloads](https://git-scm.com/downloads).
112
Once git is installed, open a **new** terminal and run:
Olivier Blanvillain's avatar
Olivier Blanvillain committed
113 114 115 116 117 118 119

```shell
git config --global core.autocrlf false
```

If this command worked it will not print anything.

Guillaume Martres's avatar
Guillaume Martres committed
120
## Step 6: Installing Code
Olivier Blanvillain's avatar
Olivier Blanvillain committed
121

Guillaume Martres's avatar
Guillaume Martres committed
122
Visual Studio Code is the IDE we strongly recommend using for this class (you are free to use any editor you want, but we won't don't have the resources to help you configure it for Scala).
Olivier Blanvillain's avatar
Olivier Blanvillain committed
123 124 125 126 127 128 129

### On Linux

See [https://code.visualstudio.com/docs/setup/linux](https://code.visualstudio.com/docs/setup/linux)

### On macOS

130
If you don't already have Code installed:
131
```shell
132
brew install --cask visual-studio-code
133
```
134 135
If it was already installed before, you will need to [enable launching it from the
command line](https://code.visualstudio.com/docs/setup/mac#_launching-from-the-command-line)
Olivier Blanvillain's avatar
Olivier Blanvillain committed
136 137 138 139

### On Windows

See [https://code.visualstudio.com/docs/setup/windows](https://code.visualstudio.com/docs/setup/windows).
Guillaume Martres's avatar
Guillaume Martres committed
140
Make sure that the checkbox "Add to PATH (available after restart)" in the
141
installer is checked.
Olivier Blanvillain's avatar
Olivier Blanvillain committed
142

Guillaume Martres's avatar
Guillaume Martres committed
143
## Step 7: Installing the Scala support for Code
Olivier Blanvillain's avatar
Olivier Blanvillain committed
144

145
Open a **new** terminal and run:
Guillaume Martres's avatar
Guillaume Martres committed
146 147 148
```scala
code --install-extension lampepfl.dotty-syntax
```
Olivier Blanvillain's avatar
Olivier Blanvillain committed
149

150 151 152
If you're on Windows and the command is not found, try closing and restarting
the terminal, if that doesn't work

Olivier Blanvillain's avatar
Olivier Blanvillain committed
153 154
## Step 8: Generate a public/private SSH key pair

155
To submit labs, you will need an SSH key. If you don't already have one, here's how to generate it:
Olivier Blanvillain's avatar
Olivier Blanvillain committed
156

Guillaume Martres's avatar
Guillaume Martres committed
157
### Step 8.1: Installing OpenSSH
Olivier Blanvillain's avatar
Olivier Blanvillain committed
158

Guillaume Martres's avatar
Guillaume Martres committed
159 160 161
#### On Ubuntu and Debian

```shell
162
sudo apt update && sudo apt install openssh-client
Olivier Blanvillain's avatar
Olivier Blanvillain committed
163 164
```

165
#### On macOS
Olivier Blanvillain's avatar
Olivier Blanvillain committed
166 167 168

Nothing to do, OpenSSH is pre-installed

169
#### On Windows
Olivier Blanvillain's avatar
Olivier Blanvillain committed
170

Guillaume Martres's avatar
Guillaume Martres committed
171
Follow the instructions under "Enable OpenSSH Client in Windows 10" on
Guillaume Martres's avatar
Guillaume Martres committed
172
[https://winaero.com/blog/enable-openssh-client-windows-10/](https://winaero.com/blog/enable-openssh-client-windows-10/)
Olivier Blanvillain's avatar
Olivier Blanvillain committed
173

Guillaume Martres's avatar
Guillaume Martres committed
174
### Step 8.2: Generating the key pair
Olivier Blanvillain's avatar
Olivier Blanvillain committed
175

Matt Bovel's avatar
Matt Bovel committed
176
Please follow [this tutorial](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent) to generate a new SSH key and add it to the ssh-agent (except the last step: you should instead add the key to Gitlab as described below). This [video](https://youtu.be/_RsP81Et12s?t=67) (from 1:07 to 4:05) might also help. 
Olivier Blanvillain's avatar
Olivier Blanvillain committed
177

178
### Step 8.3: Adding your public key on Gitlab
Olivier Blanvillain's avatar
Olivier Blanvillain committed
179 180 181

To be able to push your code, you'll need to add the public part of your key on Gitlab:
- Go to [gitlab.epfl.ch](https://gitlab.epfl.ch), log in with your EPFL account
182
- Go to [gitlab.epfl.ch/-/profile/keys](https://gitlab.epfl.ch/-/profile/keys) and copy-paste the content of the `id_rsa.pub` file created by the `ssh-keygen` command you just ran (when the command was ran it printed the location where this file was saved).
Olivier Blanvillain's avatar
Olivier Blanvillain committed
183 184
- Press `Add key`

Guillaume Martres's avatar
Guillaume Martres committed
185
## Step 9: Follow the example lab
Olivier Blanvillain's avatar
Olivier Blanvillain committed
186

Guillaume Martres's avatar
Guillaume Martres committed
187
Time to do the [example lab](example-lab.md)!