이 글은 2016년 2월 3일에 업데이트되었습니다.

  1. GitHub Pages 작업 환경
  2. Dependency Error
  3. GitHub Pages Dependency versions
  4. Gemfile (version.1)
  5. Gemfile (version.2)
  6. bundler 설치
  7. 라이브러리 업데이트
  8. 의존성 정보 재확인
  9. Jekyll 재시작

얼마전부터 TiStory 블로그에서 GitHub Pages 로 이사하는 중이다. 이유는 포스팅의 편리함 때문이다. 그렇다고 Tistory 블로그를 없앨 생각은 없다. Tistory 나름의 장점이 있기 때문에 당분간은 mirror site 로 GitHub Pages 와 Tistory 블로그를 병행 이용하려고 한다.

또한, 이 글을 검색하여 읽고 계신 분이라면 이미 github 계정이 있고 해당 계정을 본인의 장비에 clone 하여 local 에서 GitHub Pages 를 띄워보기 위해 jekyll serve 명령어를 시도해 본 분이라 생각하고 기초적인 부분에 대한 설명은 생략한다. 혹시 기초적인 내용이 궁금하신 분은 필자의 이전 글 GitHub Pages 소개 를 참고하기 바란다.

GitHub Pages 작업 환경

  1. iMac : OS X El Capitan
  2. MacBook Pro : OS X El Capitan

Dependency Error

주로 iMac 에서 포스팅을 하다가 오늘 처음으로 다른 단말기(MacBook)에서 포스팅을 시도했다가 다음과 같은 Dependency Error 가 났다.

$ cd migom.github.io
$ jekyll serve
Configuration file: /***/migom.github.io/_config.yml
            Source: /***/migom.github.io
       Destination: /***/migom.github.io/_site
 Incremental build: disabled. Enable with --incremental
      Generating... 
  Dependency Error: Yikes! It looks like you don't have pygments 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: 'cannot load such file -- pygments' If you run into trouble, you can find helpful resources at http://jekyllrb.com/help/! 
  Liquid Exception: pygments in /***/migom.github.io/_posts/***.md
             ERROR: YOUR SITE COULD NOT BE BUILT:
                    ------------------------------------
                    pygments

highlight 태그가 달려 있는 포스트를 build 할 수 없다고 한다.

Syntax Highlighting 을 위해 Pygments 를 사용하도록 설정해 두었었는데 요게 문제가 생긴 것 같다.

필자의 단말기 중 iMac 과 MacBook Pro 의 개발 환경이 서로 달랐던 모양이다.

GitHub Pages Dependency versions

다행스럽게도 GitHub Pages 는 의존성을 가지는 라이브러리에 관한 정보를 다음의 공식 사이트에 공개하고 있다.

json 을 다룰 줄 안다면 다음 페이지를 파싱하여 사용하면 되겠다.

Gemfile (version.1)

위 페이지의 의존성 정보를 참고하여 github.io 저장소의 최상위 디렉토리에 Gemfile 을 만들자.

$ vi Gemfile

source 'https://rubygems.org'

gem 'jekyll', '2.4.0'
gem 'jekyll-coffeescript', '1.0.1'
gem 'jekyll-sass-converter', '1.3.0'
gem 'kramdown', '1.9.0'
gem 'maruku', '0.7.0'
gem 'rdiscount', '2.1.8'
gem 'redcarpet', '3.3.3'
gem 'RedCloth', '4.2.9'
gem 'liquid', '2.6.2'
gem 'pygments.rb', '0.6.3'
gem 'jemoji', '0.5.0'
gem 'jekyll-mentions', '0.2.1'
gem 'jekyll-redirect-from', '0.8.0'
gem 'jekyll-sitemap', '0.9.0'
gem 'jekyll-feed', '0.3.1'
gem 'jekyll-gist', '1.4.0'
gem 'jekyll-paginate', '1.1.0'
gem 'github-pages-health-check', '0.5.3'
#gem 'ruby', '2.1.1'
gem 'github-pages', '40'
gem 'html-pipeline', '1.9.0'
gem 'sass', '3.4.16'
gem 'safe_yaml', '1.0.4'

Gemfile (version.2)

2016년 2월 3일 업데이트한 내용.

GitHub Help 페이지를 보다가 다음과 같은 내용을 발견하였다.

위에 기술한 내용처럼 각 라이브러리마다 버전 정보를 따로 관리해 주어도 되지만, 아래와 같이 간단하게 gem 'github-pages' 만 추가해 주면 알아서 github-pages 의 최신 의존성 정보를 업데이트해 준다고 한다. 훨씬 간단하다.

$ vi Gemfile

source 'https://rubygems.org'
gem 'github-pages'

bundler 설치

우선, 라이브러리 설치를 위해 패키지 매니져의 하나인 bundler 가 설치되었는지 확인하자.

$ bundle -v

bundler 가 설치되어 있다면 다음 섹션(라이브러리 업데이트)로 넘어가고,

설치되어 있지 않다면 gem 을 이용하여 bundler 를 설치하자.

$ gem install bundler

permission denied 메시지가 보인다면 super user 권한을 이용하여 설치하면 된다.

$ sudo gem install bundler

라이브러리 업데이트

아까 만들어둔 Gemfile 이 있는 경로에서 다음과 같이 라이브러리를 설치 & 업데이트하자.

$ bundle install
$ bundle update

의존성 정보 재확인

Gemfile 에 기록된 버전 정보대로 잘 설치된 것을 확인 할 수 있다.

$ github-pages versions
+---------------------------+---------+
| Gem                       | Version |
+---------------------------+---------+
| jekyll                    | 2.4.0   |
| jekyll-coffeescript       | 1.0.1   |
| jekyll-sass-converter     | 1.3.0   |
| kramdown                  | 1.9.0   |
| maruku                    | 0.7.0   |
| rdiscount                 | 2.1.8   |
| redcarpet                 | 3.3.3   |
| RedCloth                  | 4.2.9   |
| liquid                    | 2.6.2   |
| pygments.rb               | 0.6.3   |
| jemoji                    | 0.5.0   |
| jekyll-mentions           | 0.2.1   |
| jekyll-redirect-from      | 0.8.0   |
| jekyll-sitemap            | 0.9.0   |
| jekyll-feed               | 0.3.1   |
| jekyll-gist               | 1.4.0   |
| jekyll-paginate           | 1.1.0   |
| github-pages-health-check | 0.5.3   |
+---------------------------+---------+

Jekyll 재시작

맨처음 오류가 났던 로컬에서 jekyll 서버 띄우기를 재시도해 보자.

$ jekyll serve

Configuration file: /***/migom.github.io/_config.yml
            Source: /***/migom.github.io
       Destination: /***/migom.github.io/_site
      Generating... 
                    done.
 Auto-regeneration: enabled for '/***/migom.github.io'
Configuration file: /***/migom.github.io/_config.yml
    Server address: http://0.0.0.0:4000/
  Server running... press ctrl-c to stop.

마지막으로 브라우저에서 http://0.0.0.0:4000/ 페이지를 확인해 보자. 짜잔! 정상 동작한다.