Visual Studio Code and WSL2

Written on May 12, 2020

I’m not the only one playing around with running Jekyll in WSL2 for my blog:

Inspired by David’s tweet, I figured it was time I gave it a go. It was remarkably easy!

First, make sure I’m on the WSL2 disk (not the mounted Windows disk)

cd

Now pull down my blog repo

git clone https://github.com/flcdrg/flcdrg.github.io.git

Start Visual Studio Code in the current directory

code .

This magically installed some ‘server’ bits into WSL2

Updating VS Code Server to version d69a79b73808559a91206d73d7717ff5f798f23c
Removing previous installation...
Installing VS Code Server for x64 (d69a79b73808559a91206d73d7717ff5f798f23c)
Downloading: 100%
Unpacking: 100%
Unpacked 2321 files and folders to /home/david/.vscode-server/bin/d69a79b73808559a91206d73d7717ff5f798f23c.

and then Visual Studio Code launched

Visual Studio Code editing git repo in WSL2

But how can I save screenshots and other images now that the repo is stored inside WSL2? Easy as it turns out. I right-clicked on the assets folder in Code and chose Reveal in Explorer and it brings up Windows Explorer pointing to an internal share mapped back to the Linux disk. I can access the same path from the snipping tool too!

Windows Explorer in git repo in WSL2

And how fast is Jekyll?

bundle exec jekyll serve --incremental 2>&1 | grep -E -v 'deprecated|GitHub Metadata'

On Windows: 120 seconds

On Linux: 62 seconds

Categories: WSL2, Visual Studio Code