Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

wslfetch annotation 2020-07-05 102241

Config

Ubuntu on WSL
Windows Subsystem for Linux (WSL)

License


Config is a basic checklist I follow to set up a new Ubuntu's development environment. It gets me up to speed with Git, Ruby, Node.js, GitHub, Jekyll, and more so I can more quickly get back to coding.

Dotfiles

File Description
.bashrc Customizes the Terminal prompt and echoes the currently checked out Git branch.
.gitignore The Git ignore file that I use everywhere.
.gitattributes The Git attributes file that I use everywhere.

Shell script (WIP)

This repository includes a shell script for executing the bulk of the configuration process. First, install and agree to terms for WSL, then download and run Windows Terminal. Then, enter the following in Terminal:

cd $Home && mkdir -p downloads && curl https://raw.githubusercontent.com/MilanAryal/config/master/config.sh > ~/dl/config.sh && bash ~/downloads/config.sh

Table of contents

  1. Required
  2. Setup WSL
  3. Prep WSL
  4. Setup Ruby
  5. Setup Node.js

Checklist

1. Required

Ubuntu, PowerShell, Microsoft Terminal, Visual Studio Code,.. are on Microsoft Store.

2. Setup WSL

Forgot WSL password? See https://aka.ms/wslusers.

3. Prep WSL

  • Update and upgrade packages:
sudo apt update && sudo apt upgrade -y
  • Install required dependencies:
sudo apt install -y build-essential procps curl file git zlib1g-dev
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  • Setup /home/linuxbrew/.linuxbrew/bin in your PATH:
# See https://docs.brew.sh/linux for more information

# Add Homebrew to your PATH in /home/milan/.profile:
$ echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> /home/milan/.profile

$ eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"

# Install the Homebrew dependencies if you have sudo access:
$ sudo apt install -y build-essential

# We recommend that you install GCC:
$ brew install gcc

# Run `brew help` to get started
# Further documentation: https://docs.brew.sh
  • Log out then log back in to confirm the install.

Caution: Never attempt to edit Linux system files like .bashrc or .profile with a Windows text editor. Windows file metadata differs from Linux file metadata. You could corrupt or damage your Linux environment. Use Bash commands as above, or use a Linux text editor such as nano or vi. You can also use a specialized Windows editor like Notepad++ that can save text as Unix script files.

4. Setup Ruby

  • Install rbenv via Homebrew:
brew install rbenv
  • Set up rbenv in your shell. Run rbenv init:
echo 'eval "$(rbenv init -)"' >> ~/.profile
  • Add ~/.rbenv/bin to your $PATH for access to the rbenv command-line utility:
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
  • Verify rbenv is configured properly:
type rbenv
  • Verify that rbenv is properly set up using rbenv-doctor script:
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/main/bin/rbenv-doctor | bash
# Download a version of Ruby via rbenv:
$ rbenv install 2.7.4

# Make it the global version of Ruby: 
$ rbenv global 2.7.4

# Additional dependencies:
$ gem install bundler
sudo apt install -y build-essential zlib1g-dev

Installing and managing Ruby with rbenv allows us to specify versions of Ruby on a per-project basis. It also means we can avoid running sudo commands for installing gems and more as it's not affecting OS's system Ruby.

Having trouble with nokogiri? See https://stackoverflow.com/a/41491487.

5. Setup Node.js

  • Install nodenv via Homebrew:
brew install nodenv
  • Set up nodenv in your shell. Run nodenv init:
echo 'eval "$(nodenv init -)"' >> ~/.profile
  • Add ~/.nodenv/bin to your $PATH for access to the nodenv command-line utility:
echo 'export PATH="$HOME/.nodenv/bin:$PATH"' >> ~/.bashrc
  • Verify nodenv is configured properly:
type nodenv
  • Verify that nodenv is properly set up using nodenv-doctor script:
curl -fsSL https://github.com/nodenv/nodenv-installer/raw/master/bin/nodenv-doctor | bash
  • Download a version of Node.js via nodenv:
# Download a version of Node.js via nodenv:
$ nodenv install 14.18.1

# Make it the global version of Node.js: 
$ nodenv global 14.18.1

# https://www.npmjs.com/package/npm-check-updates
$ npm install -g npm-check-updates
sudo apt install -y build-essential

Installing and managing Node.js with nodenv allows us to specify versions of Node on a per-project basis. It also means we can avoid running sudo commands for installing global packages and more as it's not affecting OS's system Node.js.

↥ To the top