Previously, I started off with Jekyll using Ruby to generate this blog site on
macOS and I am stuck in trying to update this site with a Windows 10 machine
Do you desperately wanted to deploy Jekyll using Ruby on Windows?
Honestly, I tried installing Ruby with Dev Kit on Windows 10, using gem to
jekyll. But discovered it is not as easy as it seems
when I kept getting issues with some gems
commonmarker or etc.
If you google about Jekyll and Windows 10 issue, the list just goes on and on.
After so much frustration, there is a Windows solution that just get Ruby to play nicely on Windows 10 and that is to use Windows Subsystem for Linux. Let’s start bashing on Windows 10.
Getting Started with Jekyll on Windows 10 using Windows Subsystem for Linux
In this blog post, I will be documenting the basic steps to get Ruby for Jekyll working on Windows 10 using Windows Subsystem for Linux (WSL) feature.
What is actually Windows Subsystem for Linux? In short, it is a Windows feature
on Windows 10 that allows developers to run Linux environment directly on
Windows without deploying a virtual machine. That means you get to use
and many other Linux tools on Windows.
- Windows 10 Build 16215 or later
Enable Windows Subsystem for Linux feature on Windows 10
To enable the Windows Subsystem for Linux Feature on Windows 10 and reboot the Windows 10 using PowerShell
Note: A reboot of the Windows 10 operating system is required after enabling the Windows Subsystem for Linux feature
- Launch Windows PowerShell with elevated privileges
- Use the
Enable-WindowsOptionalFeaturePowerShell cmdlet to enable the feature
1 2 3 4 Enable-WindowsOptionalFeature ` -FeatureName Microsoft-Windows-Subsystem-Linux ` -Online ` -NoRestart:$False ;
Install Bash from Ubuntu distro
After the Windows 10 reboot, we can start installing
bash on the Windows 10
- Launch Command Prompt with elevated privileges
lxruncommand to install Bash from the Ubuntu distro image (default distro)
1 lxrun /install /y
Switching to Bash shell
Once the installation has completed, you can begin switching into Bash shell runing from the Linux environment from the Command Prompt or PowerShell Console on Windows 10.
Update the Bash shell image
Since the Windows Subsystem for Linux release with those packaged environment images, those images may be out of date and we will need to manually perform an update and upgrade for that Linux environment.
1 sudo apt-get update -y && sudo apt-get upgrade -y
Now that we have an up to date Linux environment, we can start installing Ruby into that Linux environment using the Bash shell.
1 2 3 sudo apt-add-repository ppa:brightbox/ruby-ng sudo apt-get update sudo apt-get install ruby2.4 ruby2.4-dev build-essential dh-autoreconf
Update Ruby Gems
With Ruby installed, let’s update those Ruby gems to make sure we are all up to date.
1 sudo gem update
Install Jekyll with Bundler
With Bash installed using Windows Subsystem for Linux on Windows 10, Ruby installed using Bash and Ruby Gems up to date in the Linux environment. We are all set to start installing Jekyll using Bash on Windows 10 with the same command that we used on macOS previously.
1 sudo gem install jekyll bundler
Finally, you can validate Jeykll installation status from Bash by validating the Jekyll version. If nothing goes wrong, the Bash will returns you the version number.
1 jekyll -v
To fully complete this demonstration, you should be able to use the
jekyll new command to generate a site and use
bundle exec jekyll serve to
generate the static web site and view the site locally on
http://127.0.0.1:4000/ loopback address on port 4000.
1 2 jekyll new my_blog bundle exec jekyll serve
That is all, folks. It is just that simple on Bash with Windows Subsystem for Linux on Windows 10 that ends my mickey mouse around with Ruby and Dev Kits on Windows.
- Microsoft Docs: Windows Subsystem for Linux Documentation
- Microsoft Docs: Windows 10 Installation Guide