Skip to content

Latest commit

 

History

History
668 lines (412 loc) · 22.8 KB

macOS.md

File metadata and controls

668 lines (412 loc) · 22.8 KB

Setup instructions

The following instructions will help you to get ready for Le Wagon fullstack bootcamp:

  • Grab a text editor, where you will spend your days and nights
  • Install a package manager
  • Pimp your Terminal
  • Setup git and GitHub
  • Install Ruby

Remote tools

To be able to interact when we are not in the same physical room, we will be using two tools:

Zoom

Zoom is a video conferencing tool. To create an account and install the app, go to https://zoom.us/download and under Zoom Client for Meetings click the Download button. Open the file you have just downloaded. A progress bar will appear, then Zoom will start. Click on Connection and create an account with the Sign Up Free option:

zoom-sign-up-free.png

Once connected, you should see:

zoom-welcome-screen.png

You can close Zoom now.

Teamviewer

For the most complicated problems, a teacher might have to take control of your computer. To be able to do this, we will need to use the Teamviewer tool. Go to the Teamviewer download page. It should automatically detect your operating system. If it doesn't, choose your operating system from the list at the top of the page. Click on Download Teamviewer and open the file you just have downloaded. Leave the default settings as they are and click on Accept. A progress bar will appear, then Teamviewer will start when the installation is over. It should look like this:

teamviewer.jpg

This will only be used as last resort when debugging becomes too tricky through spoken word. Nobody will ever be able to take control of your screen without you knowing it 👌

You can close Teamviewer now.

If you are not familiar with video calls, here is a great article full of good practices 📷 🎤

A note about quitting apps on a Mac

Clicking the little red cross in the top left corner of the application window on a Mac does not really quit it, it just closes an active window. To quit the application for real either press Cmd + Q when the application is active, or navigate to APP_NAME -> Quit in the menu bar.

quit.png

During this setup you will be asked to quit and re-open applications multiple times, please make sure you do it properly 🙏

Command Line Tools

Open a new Terminal window from Applications > Utilities or searching with Spotlight:

Copy-paste the following command in the terminal and hit Enter to execute the command.

xcode-select --install

If you receive the following message, you can just skip this step and go to next step.

# command line tools are already installed, use "Software Update" to install updates

Otherwise, it will open a window asking you if you want to install some software. Accept and wait. If it fails, try again xcode-select --install, sometimes the Apple servers are overloaded.

While it's downloading, you can go on with configuring your GitHub account, but stop before Homebrew. You'll need the command line tools installed for that step.

If you receive the following message, you need to update the sofware update catalog.

Xcode is not currently available from the Software Update server

In this case, copy-paste the following command in the terminal and hit Enter.

sudo softwareupdate --clear-catalog

Once this is done, you can try to install again (copy-paste the following command and hit enter).

xcode-select --install

Then follow the previous instructions for this command.

GitHub account

Have you signed up to GitHub? If not, do it right away.

👉 Upload a picture and put your name correctly on your GitHub account. This is important as we'll use an internal dashboard with your avatars. Please do this now, before you continue with this guide.

Homebrew

On Mac, you need to install Homebrew which is a Package Manager. It will be used as soon as we need to install some software. To do so, open your Terminal and run:

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

This will ask for your confirmation (hit Enter) and your macOS user account password (the one you use to log in when you reboot your Macbook). :warning: When typing a password in the Terminal, you will not get a visual feedback (something like *****), this is normal!! Type the password and confirm by typing Enter.

If you already have Homebrew, it will tell you so, that's fine, go on.

Then install some useful software:

brew update

If you get a /usr/local must be writable error, just run this:

sudo chown -R $USER:admin /usr/local
brew update

Error message or not, proceed running the following in the terminal (you can copy / paste all the lines at once).

brew upgrade git         || brew install git
brew upgrade gh          || brew install gh
brew upgrade wget        || brew install wget
brew upgrade imagemagick || brew install imagemagick
brew upgrade jq          || brew install jq
brew upgrade openssl     || brew install openssl

Sublime Text 3 - Your text editor

A text editor is one of the most important tools of a developer. Go to this page and download Sublime Text 3 for OS X. Install it (double click the downloaded file and drag & drop the app into the Applications folder, don't skip this). If you had Sublime Text 2 installed before, please uninstall it (by dragging/dropping it to the Trash).

Sublime Text is free without any time limitation but a popup will appear every ten saves to remind you there is a license to buy. You can hit Esc when this happens, but feel free to buy Sublime Text if you really like this one (there are alternatives).

Again, make sure that Sublime Text is there, not in the disk image you downloaded. To make sure it's correct, once Sublime Text is installed, unmount the "Sublime Text 3" disk in the left panel of Finder. Finder will complain if something went wrong. Ask a teacher.

Oh-my-zsh - Fancy your Terminal

We will use the shell named zsh instead of bash, the default one, alongside with useful and fancy oh-my-zsh plugins:

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Be careful, at the end of this script, it will prompt for your macOS user account password again (Remember! No visual feedback!). You should get something like:

         __                                     __
  ____  / /_     ____ ___  __  __   ____  _____/ /_
 / __ \/ __ \   / __ `__ \/ / / /  /_  / / ___/ __ \
/ /_/ / / / /  / / / / / / /_/ /    / /_(__  ) / / /
\____/_/ /_/  /_/ /_/ /_/\__, /    /___/____/_/ /_/
                        /____/                       ....is now installed!

Now quit the Terminal ( + Q) and restart it.

You should see something like this:

If not, stop right away and call a teacher.

On Mac, open Terminal > Preferences and set the "Pro" theme as default in Profiles (Réglages in French).

Quit and restart the Terminal. It should now have a nice black background, more easy on the eyes.

💡 There are plenty of themes available on the Internet like MaterialDark if you fancy trying another one. That's something you can configure later during the day or come back to it if you are done with your setup early. Please carry on with the Github setup!

GitHub

We need to generate SSH keys which are going to be used by GitHub and Heroku to authenticate you. Think of it as a way to log in, but different from the well known username/password couple. If you already generated keys that you already use with other services, you can skip this step.

Open a terminal and type this, replacing the email with yours (the same one you used to create your GitHub account). It will prompt for information. Just press enter until it asks for a passphrase.

mkdir -p ~/.ssh && ssh-keygen -t ed25519 -o -a 100 -f ~/.ssh/id_ed25519 -C "[email protected]"

NB: when asked for a passphrase, put something you want (and that you'll remember), it's a password to protect your private key stored on your hard drive. You'll type, nothing will show up on the screen, that's normal. Just type the passphrase, and when you're done, press Enter.

Then you need to give your public key to GitHub. Run:

cat ~/.ssh/id_ed25519.pub

It will prompt on the screen the content of the id_ed25519.pub file.

- Copy that text from ssh to the end of your email address - Go to github.com/settings/ssh - Click on the green button New SSH key - Fill in the Title with your computer name (Macbook Pro for instance) - Paste the Key - Finish by clicking on the Add key green button.

To check that this step is completed, in the terminal run this.

⚠️ You will be prompted a warning, type yes then Enter.

This is the expected result:

# Hi --------! You've successfully authenticated, but GitHub does not provide shell access

 

    ✅ If you got this message, the keys were added successfully!

    ❌ If you encountered an error, you will have to try again. Do not hesitate to contact a teacher.


🔧 Troubleshooting

If ssh -T [email protected] does not work

 

Try running this command before trying again:

ssh-add ~/.ssh/id_ed25519

Don't be in a rush, take time to read this article to get a better understanding of what those keys are used for.

GitHub CLI

CLI is the acronym of Command-line Interface.

In this section, we will install GitHub CLI to perform useful actions with GitHub data directly from the Terminal.

It should already be installed on your laptop from the previous commands. First you need to login:

gh auth login -s 'user:email' -w

You will get the following output:

- Logging into github.com

! First copy your one-time code: 0EF9-D015
- Press Enter to open github.com in your browser...

Select and copy the code (0EF9-D015 in the example), then type Enter. Your browser will open and ask you to authorize GitHub CLI to use your GitHub account. Accept and wait a bit. Come back to the terminal, type Enter again, and that should be it 🎉

To check that you are properly connected, type:

gh auth status

If you get Logged in to github.com as <YOUR USERNAME> , then all good. If not, ask a teacher.

Then run the following configuration line:

gh config set git_protocol ssh

Finally, create a gist to make sure gh is working:

echo "Hello [Le Wagon](https://www.lewagon.com) :wave:" | gh gist create -d "Starting my coding journey..." -f "SETUP_DAY.md" -p -w

This line should open your browser on the newly created gist page. See, we've just created a Markdown file!

Dotfiles (Standard configuration)

Hackers love to refine and polish their shell and tools.

We'll start with a great default configuration provided by Le Wagon: lewagon/dotfiles.

As your configuration is personal, you need your own repository storing it. Forking means that it will create a new repo in your GitHub account, identical to the original one. You'll have a new repository on your GitHub account, $GITHUB_USERNAME/dotfiles. We need to fork because each of you will need to put specific information (e.g. your name) in those files.

Open your terminal and run the following command:

export GITHUB_USERNAME=`gh api user | jq -r '.login'`
echo $GITHUB_USERNAME

You should see your GitHub username printed. If it's not the case, stop here and ask for help. There seems to be a problem with the previous step (gh auth).

Time to fork the repo and clone it on your laptop:

mkdir -p ~/code/$GITHUB_USERNAME && cd $_
gh repo fork lewagon/dotfiles --clone

Run the dotfiles installer.

cd ~/code/$GITHUB_USERNAME/dotfiles && zsh install.sh

Check the emails registered with your GitHub Account. You'll need to pick one at the next step:

gh api user/emails | jq -r '.[].email'

Run the git installer:

cd ~/code/$GITHUB_USERNAME/dotfiles && zsh git_setup.sh

☝️ This will prompt you for your name (FirstName LastName) and your email. Be careful you need to put one of the email listed above thanks to the previous gh api ... command. If you don't do that, Kitt won't be able to track your progress.

Please now quit all your opened terminal windows.

Sublime Text auto-configuration

Open a new terminal and type this:

cd ~/code
stt

It will open Sublime Text in the context of your current folder. That's how we'll use it.

Close Sublime text and open it again:

stt

Wait 1 minute for additional packages to be automatically installed (New tabs with text will automatically open, containing documentation for each new package installed). TO follow package installation, you can go to View > Show console.

To check if plugins are installed, open the Command Palette ( + + P on OSX, Ctrl + + P on Linux), type in Packlist and then Enter, you should see a couple of packages installed (like Emmet).

If you don't, please install all of them manually. The list is referenced here.

When it's done, you can close Sublime Text.

SSH Passphrase

In a terminal window, launch this command:

sw_vers
Click here if your OS version (ProductVersion line) is less than 10.12

In order not to re-type your SSH passphrase at every git push, you can add these lines to the ~/.ssh/config file:

First open the ~/.ssh/config file.

touch ~/.ssh/config  # Creates the file if it does not exist
st ~/.ssh/config     # Opens the file in Sublime text

And then add these 3 lines to the file. Save.

Host *
  AddKeysToAgent yes
  UseKeychain yes

Installing Ruby (with rbenv)

First, we need to clean up any previous Ruby installation you might have:

rvm implode && sudo rm -rf ~/.rvm
# If you got "zsh: command not found: rvm", carry on. It means `rvm` is not
# on your computer, that's what we want!

sudo rm -rf $HOME/.rbenv /usr/local/rbenv /opt/rbenv /usr/local/opt/rbenv

Now let's get rbenv and ruby-build packages from Homebrew, they'll be useful.

brew uninstall --force rbenv ruby-build

Then quit all your opened terminal windows (Cmd + Q) and restart one. Then run:

brew install rbenv

Again, quit all your terminal windows and restart.

Now, you are ready to install the latest ruby version and set it as the default version.

Run this command, it will take a while (5-10 minutes)

rbenv install 2.6.6

Once the ruby installation is done, run this command to tell the system to use the 2.6.6 version by default.

rbenv global 2.6.6

Then restart your Terminal again (close it and reopen it).

ruby -v

You should see something starting with ruby 2.6.6p. If not, ask a teacher.

Installing some gems


Click here if you are in 🇨🇳 China

 

⚠️ If you are in China, you should update the way we'll install gem with the following commands.

# China only!
gem sources --remove https://rubygems.org/
gem sources -a https://gems.ruby-china.com/
gem sources -l
# *** CURRENT SOURCES ***
# https://gems.ruby-china.com/
# Ruby-china.com must be in the list now

All, please run the following line:

gem install rake bundler rspec rubocop rubocop-performance pry pry-byebug colored http

If you encounter the following error:

ERROR: While executing gem ... (TypeError) incompatible marshal file format (can't be read) format version 4.8 required; 60.33 given

Run the following command:

rm -rf ~/.gemrc

Rerun the command to install the gems.

Never install a gem with sudo gem install! Even if you stumble upon a Stackoverflow answer (or the Terminal) telling you to do so.

Installing Node (with nvm)

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.0/install.sh | zsh

Restart your terminal and run the following:

nvm -v

You should see a version. If not, ask a teacher.

Now let's install node:

nvm install 14.15.0

When the command returns, run

node -v

You should see v14.15.0. If not, ask a teacher.

PostgreSQL

In a few weeks, we'll talk about SQL and Databases and you'll need something called PostgreSQL, an open-source robust and production-ready database. Let's install it now.

brew install postgresql
brew services start postgresql

Once you've done that, let's check if it worked:

psql -d postgres

If you enter a new prompt like this one, you're good!

psql (12.5)
Type "help" for help.

postgres=#

To quit it, type \q then Enter.

Security

It is mandatory that you protect your session behind a password.If it is not already the case, go to  > System Preferences > Users & Groups and change your account password. You should also go to  > System Preferences > Security > General. You should require a password 5 seconds after sleep or screen saver begins.

You can also go to  > System Preferences > Mission Control and click on the Hot Corners button at the bottom left. Choose for the bottom right corner to start the screen saver. That way, when you leave your desk, you can quickly lock you screen by putting your mouse in the bottom right corner. 5 seconds after, your Macbook will be locked and will ask for a password to get back on the session.

Check-up

Let's check if you successfully installed everything.

Quit all opened Terminal, open a new one and run the following commands:

curl -Ls https://raw.githubusercontent.com/lewagon/setup/master/check.rb > _.rb && ruby _.rb || rm _.rb

It should tell you if your workstation is ready :) If not, ask a teacher.

Alumni

⚠️ If you have received an email from Le Wagon inviting you to sign up on Kitt (our learning platform), you can safely skip this step. Instead, please follow the instructions in the email you received if you haven't done so already. If you are unsure about what to do, you can follow this link. If you are already logged in, you can safely skip this section. If you are not logged in, click on Enter Kitt as a Student. If you manage to login, you can safely skip this step. Otherwise ask a teacher whether you should have received an email or follow the instructions below.

Register as a Wagon alumni by going to kitt.lewagon.com/onboarding. Select your batch, sign in with GitHub and enter all your information.

Your teacher will then validate that you are indeed part of the batch. You can ask him to do it as soon as you completed the registration form.

Once the teacher has approved your profile, go to your email inbox. You should have 2 emails:

  • One from Slack, inviting you to the Le Wagon Alumni slack community (where you'll chat with your buddies and all the previous alumni). Click on Join and fill the information.
  • One from GitHub, inviting you to lewagon team. Accept it otherwise you won't be able to access the lecture slides.

Slack

Download the Slack native app from the mac App Store and sign in to lewagon-alumni organization.

Make sure you upload a picture there.

You can also sign in to Slack on your iPhone or Android device!

The idea is that you'll have Slack open all day, so that you can share useful links / ask for help / decide where to go to lunch / etc.

In case of remote tickets, you will use Slack audio or video call to get help. To ensure that everything is working fine, test your camera and microphone. If your browser is asking your permission to access your microphone and camera, click on yes.

After the test are finished, you should have green "All clear" messages at least for your microphone and camera. If not, ask a teacher.

Keyboard

As you become a programmer, you'll understand that leaving the keyboard takes a lot of time, so you'll want to minimize using the trackpad or the mouse. Here are a few tricks on OSX to help you do that:

Keyboard speed

Go to  > System Preferences > Keyboard. Set Key Repeat to the fastest position (to the right) and Delay Until Repeat to the shortest position (to the right).

Full Keyboard Access

Go to  > System Preferences > Keyboard. Click on the third tab (Shortcuts). At the bottom of the pane, click the radio button All controls. This way when you get a dialog with several options, you'll be able to type Enter to confirm, or Space to choose the cancel option. If you have more than two options, you can use tab to circle between them.

macOS For hackers

Read this script and cherry-pick some stuff you think will suit you. For instance, you can type in the terminal this one:

# Expanding the save panel by default
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint2 -bool true

# Save screenshots to the Desktop (or elsewhere)
defaults write com.apple.screencapture location "${HOME}/Desktop"

# etc..