Install Jekyll on Windows with Linux Subsystem

Introduction

This tutorial covers setting up the Linux Subsystem and using bash to build Jekyll sites. There are multiple ways to setup your environment to build Jekyll sites on Windows. The Linux Subsystem, being a bash system, will allow you to run the same scripts as the rest of the team, but it builds Jekyll sites slower than using native build tools. You can find local setup instructions here.

Linux Subsystem

Open PowerShell as Administrator and run:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

Restart your computer when prompted.

Ubuntu

Open the Microsoft Store and search for Ubuntu.

null

Click “Get”.

Once the download has completed, select “Launch”.

This will open a console window. Wait for installation to complete then you will be prompted to create your Linux user account.

Create your Linus username and password. This user account has no relationship to your Windows username and password and can be different. Read more about Linux user accounts.

If you run into problems during the install of the Linux Subsystem, check the official docs.

Git

Add the Personal Package Archive (PPA):

sudo add-apt-repository -y ppa:git-core/ppa

Update your local cache:

sudo apt update

Upgrade your git version (and everything else) to the latest avalible:

sudo apt upgrade

or; run all the above at once:

sudo add-apt-repository ppa:git-core/ppa && sudo apt update && sudo apt upgrade

Ruby

** The below $PATH commands assume you are using .bashrc for your shell configs. If you are not, make the appropriate adjustments (~/.zshrc if you’re using zsh instead of bash, for example). If you have no idea what this means and want to learn, start with this article about startup file order.

First, install a few support packages:

sudo apt install -y build-essential libreadline-dev zlib1g-dev libssl-dev

One thing well: rbenv is concerned solely with switching Ruby versions. It’s simple and predictable. If you’re not convenced, read Why choose rbenv over RVM.

Clone rbenv into ~/.rbenv and add ~/.rbenv/bin to your $PATH for access to the rbenv command-line utility:

git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL

Clone rbenv plugins into ~/.rbenv/plugins/ and add ~/.rbenv/plugins/ruby-build/bin to your $PATH for access via the command-line utility:

git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
git clone https://github.com/rkh/rbenv-whatis.git ~/.rbenv/plugins/rbenv-whatis
git clone https://github.com/rkh/rbenv-use.git ~/.rbenv/plugins/rbenv-use
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL

Install the latest version of Ruby:

rbenv install 2.5.1
rbenv global 2.5.1

Check that it installed properly:

ruby -v

Bundler

Install bundler for gem management.

gem install bundler

Note to Brad:

Tried installing ruby using rbenv the same as a regular Linux system. Got an error.

Tried instructions here: https://medium.com/@hleclerc/use-rbenv-ruby-on-windows-10-linux-wsl-a9bce8d97300

Got a dependency issue. Had to install two packages: zlib1g-dev and libssl-dev. Otherwise it seems to have installed fine.

Bundler seems to be slow. Not sure if it’s this hardware, Windows, bash, ruby, or maybe rubygems.org

Node & NPM

Follow same instructions as Linux.

Got error when installing npm packages. Set global install to home directory (https://docs.npmjs.com/getting-started/fixing-npm-permissions)

npm config set prefix '~/.npm'

** Browsersync isn’t reloading the page. Could be an npm issue. More likely it has to do with the slowness of ruby. Node is probably triggering npm packages before ruby finishes the build output. …maybe.