技ログ

Tech, etc.

Octopressで日本語の記事が書けない

Octopressで一つ記事を書いたので、 試しにアップしようとしたところ、以下のエラーが出てgenerate出来ない。

※OSはCentOS 6.5で必要最小限のパッケージしか入れていない。
https://github.com/2creatives/vagrant-centos/releases/download/v6.5.1/centos65-x86_64-20131205.box

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
$ bundle exec rake generate
## Generating Site with Jekyll
identical source/stylesheets/screen.css
---
Configuration from /app/rails_projects/blog/rasaka.github.io/_config.yml
Building site: source -> public
YAML Exception reading 2014-01-13-nfs-mount-error.markdown: invalid byte sequence in US-ASCII
/app/rails_projects/blog/rasaka.github.io/plugins/backtick_code_block.rb:13:in `gsub': invalid byte sequence in US-ASCII (ArgumentError)
  from /app/rails_projects/blog/rasaka.github.io/plugins/backtick_code_block.rb:13:in `render_code_block'
  from /app/rails_projects/blog/rasaka.github.io/plugins/octopress_filters.rb:12:in `pre_filter'
  from /app/rails_projects/blog/rasaka.github.io/plugins/octopress_filters.rb:28:in `pre_render'
  from /app/rails_projects/blog/rasaka.github.io/plugins/post_filters.rb:112:in `block in pre_render'
  from /app/rails_projects/blog/rasaka.github.io/plugins/post_filters.rb:111:in `each'
  from /app/rails_projects/blog/rasaka.github.io/plugins/post_filters.rb:111:in `pre_render'
  from /app/rails_projects/blog/rasaka.github.io/plugins/post_filters.rb:166:in `do_layout'
  from /home/vagrant/.rbenv/versions/2.1.0/gemsets/blog-octopress/gems/jekyll-0.12.1/lib/jekyll/post.rb:195:in `render'
  from /home/vagrant/.rbenv/versions/2.1.0/gemsets/blog-octopress/gems/jekyll-0.12.1/lib/jekyll/site.rb:200:in `block in render'
  from /home/vagrant/.rbenv/versions/2.1.0/gemsets/blog-octopress/gems/jekyll-0.12.1/lib/jekyll/site.rb:199:in `each'
  from /home/vagrant/.rbenv/versions/2.1.0/gemsets/blog-octopress/gems/jekyll-0.12.1/lib/jekyll/site.rb:199:in `render'
  from /home/vagrant/.rbenv/versions/2.1.0/gemsets/blog-octopress/gems/jekyll-0.12.1/lib/jekyll/site.rb:41:in `process'
  from /home/vagrant/.rbenv/versions/2.1.0/gemsets/blog-octopress/gems/jekyll-0.12.1/bin/jekyll:264:in `<top (required)>'
  from /home/vagrant/.rbenv/versions/2.1.0/gemsets/blog-octopress/bin/jekyll:23:in `load'
  from /home/vagrant/.rbenv/versions/2.1.0/gemsets/blog-octopress/bin/jekyll:23:in `<main>'

現状のロケールを確認。

1
2
3
4
5
6
7
8
9
10
$ locale -a
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_COLLATE to default locale: No such file or directory
C
POSIX
en_US
en_US.iso88591
en_US.iso885915
en_US.utf8

ja_JP.utf8を利用出来るようにする。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
$ sudo localedef -f UTF-8 -i ja_JP ja_JP.utf8
$ locale -a
C
POSIX
en_US
en_US.iso88591
en_US.iso885915
en_US.utf8
ja_JP.utf8
$ locale
LANG=ja_JP.utf8
LC_CTYPE="ja_JP.utf8"
LC_NUMERIC="ja_JP.utf8"
LC_TIME="ja_JP.utf8"
LC_COLLATE="ja_JP.utf8"
LC_MONETARY="ja_JP.utf8"
LC_MESSAGES="ja_JP.utf8"
LC_PAPER="ja_JP.utf8"
LC_NAME="ja_JP.utf8"
LC_ADDRESS="ja_JP.utf8"
LC_TELEPHONE="ja_JP.utf8"
LC_MEASUREMENT="ja_JP.utf8"
LC_IDENTIFICATION="ja_JP.utf8"
LC_ALL=

/etc/sysconfig/i18nを修正。

1
2
3
$ vim /etc/sysconfig/i18n
-LANG="en_US.UTF-8"
+LANG="ja_JP.utf8"

/etc/sysconfig/i18nを再読み込みで解決。

1
$ . /etc/sysconfig/i18n