Title photo
frugal technology, simple living and guerrilla large-appliance repair
Wed, 05 Apr 2017

Managing Ode with Unison via the Windows Subsystem for Linux

Update: While it seems fairly easy and routine to create and edit files on the Windows side of the filesystem using both Windows and WSL/Linux applications, when I tried to use the WSL-based Unison to sync files onto the Windows filesystem, I got a ton of permission errors and a failed sync. So the "dream" of maintaining a Windows system with WSL utilities probably won't happen. The two solutions for this particular problem are a) use Windows utilities on the Windows side and b) use Linux utilities on the WSL side.

The original entry begins here:

Now that I have my new HP Envy 15-as133cl laptop running Windows 10 and have added the Windows Subsystem for Linux, I'm exploring just how many of my regular Linux tasks I can do in this Ubuntu-supplied Bash shell, what I can do with similar programs compiled for Windows, and what really needs a dedicated Linux partition (or full computer).

Chief among these tasks is updating/syncing/backing up my Ode-generated blog (the one you're reading right now).

The first thing I learned about the Windows Subsystem for Linux (WSL for short) is that you can access the files you create in the WSL via the Windows file manager, but any modifications you make on the Windows side will not, I repeat WILL NOT be reflected in what you can see on the Linux side.


That means you can't dump a bunch of files from Windows into the Linux system and then have the ability to work with them. You can't edit your Linux files with editors on the Windows side and have any changes actually track through.

This is how the system is "designed," or at any rate how it is. Some have suggested setting up symlinks from the Windows files into the Linux system, but I've never been a "set up a bunch of symlinks" type of person.

Once I absorbed this limitation of the WSL, I had to decide, could I manage the Ode blog in Windows, or would I have to do it in Linux.

I use Unison for file syncing, doing so over an ssh connection. I also use wget to create a static archive page (though I could just as easily use curl, which would make the whole thing more Mac-friendly as curl ships in the default Bash shell for Macintosh and wget does not).

The first thing I did was get Unison for Windows. But I got stopped on the ssh part. There seem to be a couple of ssh implementations for Windows, but I needed one that works on the Windows command line, and everything seems old and unmaintained -- which in a nutshell is one of Windows' biggest weaknesses (old "free" software that hasn't been touched in years).

So it was back to the WSL, where I had already installed Unison 2.40 (the version my server uses; and when it comes to Unison, you really need the same version of the utility on both sides of the connection). I created new ssh keys in the WSL, copied my new public key to the server, and I was ready to roll. I modified my .prf file so it would work in the WSL, and then I used Unison to sync the entire Ode filesystem on the server with the until-now empty directory I created for this purpose. I made sure to use Unison's -batch switch so Unison would sync the entire filesystem without prompting me for every one of the 1000+ files it contains.

Now I have my blog's entire filesystem mirrored in the WSL, and I can update the blog by creating a file in the WSL adn then using Unison to sync it and then running my script (using wget) to create the static archive page.

The only "problem," is that I have to work in the WSL with Linux console programs. And there are no GUIs here. I've read that you can get GUI software to run in the WSL, but for now I don't want to jump through any hoops, so that means I'm using console-based editors to create and edit these text files. For me (and for now), that means using Vim as my editor.

So now I have my blog's entire filesystem mirrored in the WSL, and I can update the blog by creating a file in the WSL adn then using Unison to sync it and then running my script (using wget) to create the static archive page.

The only "problem," is that I have to work in the WSL with Linux console programs. And there are no GUIs here. I've read that you can get GUI software to run in the WSL, but for now I don't want to jump through any hoops, so that means I'm using console-based editors to create and edit these text files. For me (and for now), that means using Vim as my editor.

When it comes to getting images into the WSL filesystem, what is working for me so far is using the Bash shell in the WSL to navigate to /mnt/c and eventually my Windows user files, then copying those files into the WSL home directory. I just tested that, and it works. This same method will work for text files that I have created in Windows: They can be copied into the WSL area via the Bash shell.

Another thing I'm trying to get the hang of: Copy/pasting URLs from the address bar in Google Chrome into these Vim files on the WSL. I kind of, sort of got it to work, copying the traditional way in Windows and right-clicking to paste intoVim files in the terminal. (Quick Edit mode was already enabled on my WSL.)

The upshot of all this is that I have the opportunity to get a whole lot better in Vim.

tl;dr: I can manage my blog, which creates entries via static files, in the Windows Subsystem for Linux via utilities and console editors available in the WSL itself and the Bash scripts I originally created for "real" Linux use.