GitHub PagesのJekyllでError: jekyll-remote-theme が発生した

GitHub PagesのJekyllで公開しているサイトがあるのですがbundle updateしたら若干はまったのでメモ。

Summary

  • GitHub PagesのJekyllを使っているプロジェクトでbundle updateしたらローカル環境で実行時にエラーが発生した
    • 発生したエラーはError: jekyll-remote-theme
    • 環境はUbuntu 16.04.3 LTS、Ruby 2.4.3
  • ibcurl4-openssl-devUbuntuにインストールすることで解消した

ことの始まり

先日こんなメールがGitHubから届きました。

f:id:braitom:20180118164740p:plain

「これが噂のDependency graphの機能で脆弱性のあるライブラリを通知してくれているのかー最高に便利だな」と思いました。

ということでアップデートを開始。

環境

今回問題が発生した環境は以下です。

やったこと

Gemfileの確認

GitHub Pagesのgemはこんな感じになっていると思います。

source "https://rubygems.org"

gem 'github-pages', group: :jekyll_plugins

bundle updateの実施

アップデートします。

$ > bundle update

何のエラーもなくアップデートできました。Gemfile.lock もきちんと更新され、中を見ると問題のnokogiri もアップデートされていることを確認しました。

動作確認、エラー発生

ローカルで動作確認をします。

$ > bundle exec jekyll serve
Configuration file: /mnt/c/Users/xxx/xxx/_config.yml
  Dependency Error: Yikes! It looks like you don't have jekyll-remote-theme or one of its dependencies installed. In order
to use Jekyll as currently configured, you'll need to install this gem. The full error message from Ruby is: 'Could not open library 'libcurl': libcurl: cannot open shared object file: No such file or directory. Could not open library 'libcurl.so': libcurl.so: cannot open shared object file: No such file or directory. Could not open library 'libcurl.so.4': libcurl.so.4: cannot open shared object file: No such file or directory' If you run into trouble, you can find helpful resources at https://jekyllrb.com/help/!
jekyll 3.6.2 | Error:  jekyll-remote-theme

おや、なんかエラーが出てる。Error: jekyll-remote-theme ってやつですね。

対応策

調べたところjekyllのリポジトリにそれっぽいIssueが上がっているのを見つけました。

Dependency Error: jekyll-remote-theme is not installed · Issue #6660 · jekyll/jekyll

まさにこれですね。

いろいろ書かれていますが、私の環境では下の方にあるようにibcurl4-openssl-devを入れることで解決しました。

$ > sudo apt install libcurl4-openssl-dev

これでもう一度、bundle exec jekyll serve を実行したところエラーが解消されました。

さいごに

あとはPushすれば無事にGitHubが出しているセキュリティアラートも消えていると思います。
しかし、Dependency graph便利ですね。もっと色んな言語に対応してくれるとありがたいものです。