未加星标

Using Windows Subsystem for Linux and Ruby with Jekyll

字体大小 | |
[系统(linux) 所属分类 系统(linux) | 发布者 店小二05 | 时间 2018 | 作者 红领巾 ] 0人收藏点击收藏
The Goal / Problem

This blog has been around for a little bit now. I’m bound to have some dead links or images. I figured I’d check those out and clean up the place.

Luckily, this blog also runs on Jekyll and Ruby, and the ruby ecosystem has a great gem called html-proofer that will help us do this.

So I added the gem to my project, installed it, and ran html-proofer, only to see:

(LoadError)y23/lib/ruby/gems/2.3.0/gems/ffi-1.9.18-x64-mingw32/lib/ffi/library.rb:147:in `block in ffi_lib’: Could not open library ‘libcurl’: The specified module could not be found. Could not open library ‘libcurl.so.4.dll’: The specified module could not be found.

That’s…not great. I googled a bunch and it appears that some of the tools in that chain don’t play well with windows, and I wasn’t able to find a solution quickly. So I was about to give up on the task for a bit rather than fighting the Ruby/Windows ecosystem.

…until I remembered that I could bring linux right into my environment and get the job done.

The Solution: Enter Windows Subsystem for Linux (WSL)

If you haven’t heard of Windows System for Linux (WSL) , it’s a fantastic project from Microsoft that allows you to run certain Linux distributions right from within Windows, allowing you to get the best of both worlds.

I figured it was worth giving it a shot. Boy, was I right.

Obtaining WSL

I opened the Microsoft Store App and searched for “Ubuntu”. I found the Ubuntu distribution from Canonical and clicked Install . When that was done, I clicked Launch .

I waited a few minutes for some setup to complete, followed the prompts to create a username and password, and then I had a shell ready to go.

…was it really that straight-forward? Indeed it was.

Installing Ruby

RVM seemed like the right way to go to install and manage versions of Ruby, so I decided to use that.

I followed the install instructions . All of the below steps were performed within the Ubuntu window.

gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB sudo apt-get install software-properties-common sudo apt-add-repository -y ppa:rael-gc/rvm sudo apt-get update sudo apt-get install rvm

After RVM installs, it prints out some additional instructions, so I also:

sudo usermod -a -G rvm sean source /etc/profile.d/rvm.sh logout

I then used RVM to install Ruby: rvm install ruby

Cool! I’ve got Ruby.

Git Install and Clone

I’ve got to get to my blog’s repository in order to build it and run html-proofer. That means setting up git with the GitHub repo. I:

sudo apt-get install git git config --global user.name "SeanKilleen" git config --global user.email "SeanKilleen@gmail.com" git clone https://github.com/SeanKilleen/seankilleen.github.io Building the Blog

I need to:

cd seankilleen.github.io gem install bundler bundle install

Now, I can build the blog via bundle exec jekyll build

And it works! Not shabby.

Adding html-proofer (from Windows!)

OK, so I need to add the html-proofer gem by modifying the gemfile that’s sitting on my Ubuntu distro. But ugh, I don’t know the landscape as well as I know the windows landscape, and I’d rather just quickly use notepad.

…Thankfully, you can totally edit the Linux distro files from within Windows!

I:

C:\Users\%USERNAME%\AppData\Local\Packages CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc \LocalState\rootfs\home\sean

Whoa, there’s my repo folder! I just need to click into the seankilleen.github.io folder, and then I can open gemfile within notepad.

gem 'html-proofer' cat gemfile

It would be pretty great to commit those changes to GitHub right from my Ubuntu distro. Is that doable?

…Heck yeah, it’s doable.

Setting up my GitHub account for push within WSL

Pushing to GitHub requires a personal access token when you have two-factor authentication turned on (as you should!). So, I:

Open a web browser on Windows and head to https://github.com/settings/tokens Create a personal access token and save it somewhere that you would save a password (because it essentially is one) Switch back to my Ubuntu WSL window Navigate to the repo folder if I’m not already in it Add my uncommitted files: git add . Check with git status Commit the change: git commit -m "Adding html-proofer gem" Attempt to push the change: git push Enter username and personal access token in place of the password

Now I’ve committed the change to my repo, from Ubuntu.

The payoff: Running html-proofer without issue!

In my WSL window, I:

Navigate to the repo folder Run bundle install to make sure I’ve got everything installed Run bundle exec jekyll build to create the output, which lives in a _site folder. Run bundle exec html-proofer ./_site to execute html-proofer.

Voila! I see the output.

Wow. That was cool.

The team behind WSL has put in a ton of work to make this experience seamless. A small bit of googling let me follow instructions to get up and running on Ubuntu without sacrificing the ease and muscle memory of the Windows environment as my main setup.

I hope this helps serve as an introduction to Windows Subsystem for Linux. But if you’ll excuse me for now, I have some links to go fix!

Using Windows Subsystem for Linux and Ruby with Jekyll was originally published by Sean Killeen at SeanKilleen.com on September 14, 2018.

本文系统(linux)相关术语:linux系统 鸟哥的linux私房菜 linux命令大全 linux操作系统

tags: my,Windows,html,install,Linux,Ubuntu,proofer
分页:12
转载请注明
本文标题:Using Windows Subsystem for Linux and Ruby with Jekyll
本站链接:https://www.codesec.net/view/597060.html


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 系统(linux) | 评论(0) | 阅读(24)