Last modified on 19 Oct 2020.

WSL on Windows

πŸ‘‰ Main tutorial.

# Eanble Windows Subsystem for Linux
# PowerShell as Admin
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

# Enable Virtual Machine Platform (for WSL2)
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

# restart required
# Download and install WSL2 Linux kernel update package for x64 machines
https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi
# Set WSL2 as default version
# PowerShell as Admin
wsl --set-default-version 2
# Go to Windows Store
# Choose a Linux Distro and install it

Location

  • The C drive is located in /mnt/c/.
  • The Download folder is located in /mnt/c/Users/dinha/Downloads/.
  • Open current folder (in WSL2) with Windows Explorer: explorer.exe ..

Dependencies

sudo apt-get update
sudo apt-get install git-core curl wget fontconfig zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev

Windows Terminal & Zsh

# (Optional) Install Windows Terminal
https://docs.microsoft.com/en-us/windows/terminal/get-started

Change default setting theme to Linux Distro!

# Install Zsh
sudo apt-get install zsh
zsh --version

# make default
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
# exit all windows and reopen

# check version
echo $SHELL # /usr/bin/zsh  or similar

Continue to this note with following remarks:

  • Have to install fonts before!
  • Choose powerlevel10k theme instead!
  • Just run p10k configure (the icon fonts may be not working but don’t worry!)

Jekyll on WSL2

Remark: We should clone a new version from Github to the local (inside wsl) machine.

sudo apt-get install -y ruby-full build-essential zlib1g-dev
which ruby

# Make sure we don't use gem on Windows system
which gem # /usr/bin/ruby

source ~/.zshrc
# restart Windows Terminal

sudo gem install bundler

# cd to jekyll theme folder
bundle install

# continue as usual
bundle exec jekyll build # 1st time after installing
bundle exec jekyll serve
bundle exec jekyll serve -I
# Troubleshoot: Could not find a JavaScript runtime
sudo apt-get install libv8-dev
bundle update
# install nodejs
curl -sL https://deb.nodesource.com/setup_14.x | bash -
sudo apt-get install -y nodejs
# Troubleshoot: wsl2 jekyll auto generation windows
# Clone a repo to wsl local, not clone by git on Windows!

VSCode + WSL2 + jekyll

  1. Install extension Remote-WSL
  2. Connect via Debian instead! (><SWL: Debian)

WSL with cmder

Settings > Startup > Tasks > +

# for debian
set PATH="%ConEmuBaseDirShort%\wsl";%PATH% & wsl -d debian
# for ubuntu
set PATH="%ConEmuBaseDirShort%\wsl";%PATH% & wsl -d ubuntu

Choose font Cascadia Code in General > Fonts.