Where Does My Money Go? 石巻版制作にあたり Windows 環境で Jekyll をセットアップ、クローンサイトを立ち上げましたのでその手順を共有します。
『Windows PC での「Spending.jp クローンサイトの立ち上げ手順 (OpenSpending 対応版)」実行マニュアル』に「windows だとこの作業はいろいろ大変なので (^_^;」とあるように一筋縄ではいかない作業でしたが、ポイントさえ押さえればそれ程複雑な作業ではありません。
このドキュメントは、Ruby/Jekyll をインストールした事がない方、もしくはインストールされていない Windows 7/8 PC を対象に書かれています。
私が試行した環境は Windows7 32bit, Windows8 64bit です。
どちらの環境でも同じ操作を実施しました。
RubyInstaller for Windowsサイトの Download Archives より、Ruby 1.9.3-p194 をダウンロード、インストールします。
最新版でなく 1.9.3-p194 なのは、Spending.jp でこのバージョンが使われているためです。
参照:『Spending.jp クローンサイトの立ち上げ手順 (OpenSpending 対応版)』
余談:
実は最初に最新版(今回はRuby 2.0.0-p195)で構築しようとしたのですが、結果的には断念しました。すみません。
同じく Download Archives より DevKits をダウンロードします。
今回は DevKit-tdm-32-4.5.2-20110712-1620-sfx.exe を使いました。
実行するとパスを聞かれるので、先ほど Ruby がインストールされた C:\Ruby193
の下に dev
というフォルダを作り、C:\Ruby193\dev
を指定しました。C:\devkits
などでも問題ありません。
コマンドプロンプト(管理者権限不要)で DevKit の初期化、インストール
ruby dk.rb init
C:\Ruby193\dev>ruby dk.rb init
[INFO] found RubyInstaller v1.9.3 at C:/Ruby193
Initialization complete! Please review and modify the auto-generated
'config.yml' file to ensure it contains the root directories to all
of the installed Rubies you want enhanced by the DevKit.
ruby dk.rb install
C:\Ruby193\dev>ruby dk.rb install
[INFO] Updating convenience notice gem override for 'C:/Ruby193'
[INFO] Installing 'C:/Ruby193/lib/ruby/site_ruby/devkit.rb'
動作確認
gem install rdiscount --platform=ruby
ruby -rubygems -e "require 'rdiscount'; puts RDiscount.new('**Hello World**').to_html"
C:\Ruby193\dev>gem install rdiscount --platform=ruby
Fetching: rdiscount-2.1.6.gem (100%)
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
Successfully installed rdiscount-2.1.6
1 gem installed
Installing ri documentation for rdiscount-2.1.6...
Installing RDoc documentation for rdiscount-2.1.6...
C:\Ruby193\dev>ruby -rubygems -e "require 'rdiscount'; puts RDiscount.new('**Hello World**').to_html"
<p><strong>Hello World</strong></p>
Jekyll のインストール
gem install jekyll
C:\Ruby193\dev>gem install jekyll
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
Fetching: classifier-1.3.3.gem (100%)
Fetching: directory_watcher-1.4.1.gem (100%)
Fetching: syntax-1.0.0.gem (100%)
Fetching: maruku-0.6.1.gem (100%)
Fetching: kramdown-1.0.2.gem (100%)
Fetching: yajl-ruby-1.1.0-x86-mingw32.gem (100%)
Fetching: posix-spawn-0.3.6.gem (100%)
Building native extensions. This could take a while...
Fetching: pygments.rb-0.5.1.gem (100%)
Fetching: highline-1.6.19.gem (100%)
Fetching: commander-4.1.3.gem (100%)
Fetching: safe_yaml-0.7.1.gem (100%)
Fetching: colorator-0.1.gem (100%)
Fetching: jekyll-1.0.3.gem (100%)
Successfully installed fast-stemmer-1.0.2
Successfully installed classifier-1.3.3
Successfully installed directory_watcher-1.4.1
Successfully installed syntax-1.0.0
Successfully installed maruku-0.6.1
Successfully installed kramdown-1.0.2
Successfully installed yajl-ruby-1.1.0-x86-mingw32
Successfully installed posix-spawn-0.3.6
Successfully installed pygments.rb-0.5.1
Successfully installed highline-1.6.19
Successfully installed commander-4.1.3
Successfully installed safe_yaml-0.7.1
Successfully installed colorator-0.1
Successfully installed jekyll-1.0.3
14 gems installed
Installing ri documentation for fast-stemmer-1.0.2...
Installing ri documentation for classifier-1.3.3...
Installing ri documentation for directory_watcher-1.4.1...
Installing ri documentation for syntax-1.0.0...
Installing ri documentation for maruku-0.6.1...
Couldn't find file to include 'MaRuKu.txt' from lib/maruku.rb
Installing ri documentation for kramdown-1.0.2...
Installing ri documentation for yajl-ruby-1.1.0-x86-mingw32...
Installing ri documentation for posix-spawn-0.3.6...
Installing ri documentation for pygments.rb-0.5.1...
unable to convert U+2014 from UTF-8 to Windows-31J for lib/pygments/popen.rb, skipping
Installing ri documentation for highline-1.6.19...
Installing ri documentation for commander-4.1.3...
Installing ri documentation for safe_yaml-0.7.1...
Installing ri documentation for colorator-0.1...
Installing ri documentation for jekyll-1.0.3...
Installing RDoc documentation for fast-stemmer-1.0.2...
Installing RDoc documentation for classifier-1.3.3...
Installing RDoc documentation for directory_watcher-1.4.1...
Installing RDoc documentation for syntax-1.0.0...
Installing RDoc documentation for maruku-0.6.1...
Couldn't find file to include 'MaRuKu.txt' from lib/maruku.rb
Installing RDoc documentation for kramdown-1.0.2...
Installing RDoc documentation for yajl-ruby-1.1.0-x86-mingw32...
Installing RDoc documentation for posix-spawn-0.3.6...
Installing RDoc documentation for pygments.rb-0.5.1...
unable to convert U+2014 from UTF-8 to Windows-31J for lib/pygments/popen.rb, skipping
Installing RDoc documentation for highline-1.6.19...
Installing RDoc documentation for commander-4.1.3...
Installing RDoc documentation for safe_yaml-0.7.1...
Installing RDoc documentation for colorator-0.1...
Installing RDoc documentation for jekyll-1.0.3...
いくつかエラーが出ていますが問題ありませんでした。
以下のようなエラーが出た場合は環境変数 http_proxy set http_proxy=プロキシサーバー
を設定して下さい。
C:\Ruby193\dev>gem install jekyll
ERROR: Could not find a valid gem 'jekyll' (>= 0) in any repository
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
Errno::ETIMEDOUT: A connection attempt failed because the connected party di
d not properly respond after a period of time, or established connection failed
because connected host has failed to respond. - connect(2) (http://rubygems.org/
latest_specs.4.8.gz)
この後は『Spending.jp クローンサイトの立ち上げ手順 (OpenSpending 対応版)』通りなのですが、少し補足します。
今回初めて Ruby(1.9.3-p194) をインストールした方は
rbenv local 1.9.3-p194
は必要ありません。
参照:rbenvでRubyの環境を作る
gem install bundler
から実行します。
E:\src\Git>gem install bundler
Fetching: bundler-1.3.5.gem (100%)
Successfully installed bundler-1.3.5
1 gem installed
Installing ri documentation for bundler-1.3.5...
Installing RDoc documentation for bundler-1.3.5...
cloneしたプロジェクトのディレクトリ(今回の例では E:\src\Git\IshinomakiSpending )へ移動して、
bundle install --path vendor/bundler
E:\src\Git\IshinomakiSpending>bundle install --path vendor/bundler
Fetching source index from https://rubygems.org/
Could not verify the SSL certificate for https://rubygems.org/.
There is a chance you are experiencing a man-in-the-middle attack, but most
likely your system doesn't have the CA certificates needed for verification. For
information about OpenSSL certificates, see bit.ly/ruby-ssl. To connect without
using SSL, edit your Gemfile sources and change 'https' to 'http'.
エラーになります。
『bundle install で Gem::RemoteFetcher::FetchError になるCommentsAdd Starthanks3dsShinji_041』を参考に Gemfile をテキストエディタで開き、https を http に変更しました。
修正前
source 'https://rubygems.org'
修正後
source 'http://rubygems.org'
再度 bundle install --path vendor/bundler
E:\src\Git\IshinomakiSpending>bundle install --path vendor/bundler
Fetching gem metadata from http://rubygems.org/........
Fetching gem metadata from http://rubygems.org/..
Resolving dependencies...
Installing rake (10.0.3)
Installing RedCloth (4.2.9)
Installing fast-stemmer (1.0.2)
Installing classifier (1.3.3)
Installing directory_watcher (1.4.1)
Installing kramdown (0.13.8)
Installing liquid (2.4.1)
Installing syntax (1.0.0)
Installing maruku (0.6.0)
Installing posix-spawn (0.3.6)
Installing yajl-ruby (1.1.0)
Installing pygments.rb (0.3.7)
Installing jekyll (0.12.0)
Installing rdiscount (1.6.8)
Installing redcarpet (2.1.1)
Using bundler (1.3.5)
Your bundle is complete!
It was installed into ./vendor/bundler
成功しました。
これでセットアップ完了のはずなので
bundle exec rake preview
してみます。
E:\src\Git\IshinomakiSpending>bundle exec rake preview
jekyll --server --auto
E:/src/Git/IshinomakiSpending/vendor/bundler/ruby/1.9.1/gems/maruku-0.6.0/lib/maruku/input/parse_doc.rb:22:in `<top (required)>': iconv will be deprecated in the future, use String#encode instead.
Configuration from E:/src/Git/IshinomakiSpending/_config.yml
Auto-regenerating enabled: . -> ./_site
[2013-07-02 15:23:56] regeneration: 1986 files changed
YAML Exception reading default.html: invalid byte sequence in Windows-31J
YAML Exception reading default2.html: invalid byte sequence in Windows-31J
YAML Exception reading about.html: invalid byte sequence in Windows-31J
YAML Exception reading bubbletree-map.html: invalid byte sequence in Windows-31J
YAML Exception reading bubbletree.html: invalid byte sequence in Windows-31J
YAML Exception reading contact.html: invalid byte sequence in Windows-31J
[2013-07-02 15:23:56] INFO WEBrick 1.3.1
[2013-07-02 15:23:56] INFO ruby 1.9.3 (2012-04-20) [i386-mingw32]
[2013-07-02 15:23:56] INFO WEBrick::HTTPServer#start: pid=7772 port=4000
YAML Exception reading index.html: invalid byte sequence in Windows-31J
YAML Exception reading index2.html: invalid byte sequence in Windows-31J
YAML Exception reading links.html: invalid byte sequence in Windows-31J
YAML Exception reading sources.html: invalid byte sequence in Windows-31J
YAML Exception reading team.html: invalid byte sequence in Windows-31J
YAML Exception reading basic.yml: invalid byte sequence in Windows-31J
YAML Exception reading threshold.yml: invalid byte sequence in Windows-31J
Liquid Exception: invalid byte sequence in Windows-31J in default
E:/src/Git/IshinomakiSpending/vendor/bundler/ruby/1.9.1/gems/liquid-2.4.1/lib/liquid/template.rb:141:in `split'
E:/src/Git/IshinomakiSpending/vendor/bundler/ruby/1.9.1/gems/liquid-2.4.1/lib/liquid/template.rb:141:in `tokenize'
E:/src/Git/IshinomakiSpending/vendor/bundler/ruby/1.9.1/gems/liquid-2.4.1/lib/liquid/template.rb:58:in `parse'
E:/src/Git/IshinomakiSpending/vendor/bundler/ruby/1.9.1/gems/liquid-2.4.1/lib/liquid/template.rb:46:in `parse'
E:/src/Git/IshinomakiSpending/vendor/bundler/ruby/1.9.1/gems/jekyll-0.12.0/lib/jekyll/convertible.rb:101:in `do_layout'
E:/src/Git/IshinomakiSpending/vendor/bundler/ruby/1.9.1/gems/jekyll-0.12.0/lib/jekyll/post.rb:195:in `render'
E:/src/Git/IshinomakiSpending/vendor/bundler/ruby/1.9.1/gems/jekyll-0.12.0/lib/jekyll/site.rb:200:in `block in render'
E:/src/Git/IshinomakiSpending/vendor/bundler/ruby/1.9.1/gems/jekyll-0.12.0/lib/jekyll/site.rb:199:in `each'
E:/src/Git/IshinomakiSpending/vendor/bundler/ruby/1.9.1/gems/jekyll-0.12.0/lib/jekyll/site.rb:199:in `render'
E:/src/Git/IshinomakiSpending/vendor/bundler/ruby/1.9.1/gems/jekyll-0.12.0/lib/jekyll/site.rb:41:in `process'
E:/src/Git/IshinomakiSpending/vendor/bundler/ruby/1.9.1/gems/jekyll-0.12.0/bin/jekyll:253:in `block in <top (required)>'
E:/src/Git/IshinomakiSpending/vendor/bundler/ruby/1.9.1/gems/directory_watcher-1.4.1/lib/directory_watcher.rb:580:in `call'
E:/src/Git/IshinomakiSpending/vendor/bundler/ruby/1.9.1/gems/directory_watcher-1.4.1/lib/directory_watcher.rb:580:in `block in notify_observers'
E:/src/Git/IshinomakiSpending/vendor/bundler/ruby/1.9.1/gems/directory_watcher-1.4.1/lib/directory_watcher.rb:579:in `each'
E:/src/Git/IshinomakiSpending/vendor/bundler/ruby/1.9.1/gems/directory_watcher-1.4.1/lib/directory_watcher.rb:579:in `notify_observers'
E:/src/Git/IshinomakiSpending/vendor/bundler/ruby/1.9.1/gems/directory_watcher-1.4.1/lib/directory_watcher.rb:334:in `block in initialize'
E:/src/Git/IshinomakiSpending/vendor/bundler/ruby/1.9.1/gems/directory_watcher-1.4.1/lib/directory_watcher/scanner.rb:224:in `call'
E:/src/Git/IshinomakiSpending/vendor/bundler/ruby/1.9.1/gems/directory_watcher-1.4.1/lib/directory_watcher/scanner.rb:224:in `notify'
E:/src/Git/IshinomakiSpending/vendor/bundler/ruby/1.9.1/gems/directory_watcher-1.4.1/lib/directory_watcher/scanner.rb:102:in `run_once'
E:/src/Git/IshinomakiSpending/vendor/bundler/ruby/1.9.1/gems/directory_watcher-1.4.1/lib/directory_watcher/scanner.rb:150:in `run_loop'
E:/src/Git/IshinomakiSpending/vendor/bundler/ruby/1.9.1/gems/directory_watcher-1.4.1/lib/directory_watcher/scanner.rb:45:in `block in start'
Build Failed
エラーになります。
『Windows環境でinvalid byte sequence in Windows-31Jになる場合(Ruby 1.9.2)』を参考に、
set LANG=ja_JP.UTF-8
します。
再度 bundle exec rake preview
E:\src\Git\IshinomakiSpending>bundle exec rake preview
jekyll --server --auto
E:/src/Git/IshinomakiSpending/vendor/bundler/ruby/1.9.1/gems/maruku-0.6.0/lib/maruku/input/parse_doc.rb:22:in `<top (required)>': iconv will be deprecated in the future, use String#encode instead.
Configuration from E:/src/Git/IshinomakiSpending/_config.yml
Auto-regenerating enabled: . -> ./_site
[2013-07-02 15:28:02] regeneration: 1986 files changed
[2013-07-02 15:28:03] INFO WEBrick 1.3.1
[2013-07-02 15:28:03] INFO ruby 1.9.3 (2012-04-20) [i386-mingw32]
[2013-07-02 15:28:03] INFO WEBrick::HTTPServer#start: pid=6752 port=4000
動きました!
http://localhost:4000/ にアクセスして、サイトが表示されれば終了です。
お疲れ様でした。