Ruby.Jekyll的安装

2016.01.09 Updated

自己写的Jekyll主题: Jekyll主题-Project Gaia

就是这个博客的稳定版

Ruby.Download

点击这个网址下载:http://jekyll-windows.juthilo.com/1-ruby-and-devkit/

  • 下载Ruby和DevKit,注意版本要相同,安装和解压对应文件
  • 64b系统建议也用32b
  • 建议设置一下环境变量,把Ruby放到Path里面

Ruby.Init

ruby dk.rb init
ruby dk.rb install

经常install会失败,那是因为没有更新对应的ruby list

到DevKit文件夹找到config.yml文件

加入以下代码,指向的是自己的Ruby的路径

---
- D:/Ruby22

注意横杠也要写进去

低版本可能需要写两行

Ruby.Finish

安装成功的话输入以下代码可以看到版本

D:\Tools_For_Work\Projs>ruby --version
ruby 2.2.2p95 (2015-04-13 revision 50295) [i386-mingw32]

Jekyll.Install

安装Jekyll

D:\Tools_For_Work\Projs>gem install jekyll

这里会有各种错误

ERROR:  Could not find a valid gem 'jekyll' (>= 0), here is why:
 Unable to download data from http://ruby.taobao.org/ - bad respons
t Found 404 (http://ruby.taobao.org/specs.4.8.gz)

这样是因为对应的Ruby Source无法找到报404了

只需要修改RubySource即可

很多时候,在安装gem的过程中会出现找不到资源的error,我们需要从另外一个gem服务器下载安装。 通过gem sources命令配置源,或通过修改Gemfile中的source语句可以实现。

常用的源

  • http://rubygems.org/
  • http://gems.github.com
  • http://gems.rubyforge.org
  • http://ruby.taobao.org

适合安装大多数常见的gem1

显示当前使用的sources

gem sources

添加一个source

gem sources -a url地址

删除一个source

gem sources -r url地址

更新source cache

gem sources -u

添加几个Source后重新下载

Jekyll.Installation.Issues

plugins/convert.rb:32:in `': cannot load such file -- jekyll/post (LoadError)

这次Deploy的时候这个问题困扰了我好久

大多数问题都是升级引发的问题

一旦我把对应的Proj进行jekyll build的时候就报错

D:\Tools_For_Work\Projs\Github Blog>jekyll b
Configuration file: D:/Projs/Github Blog/_config.yml
D:/Projs/Github Blog/_plugins/debug.rb:13:in `<module:Jekyll>': c
annot load such file -- jekyll/post (LoadError)
from D:/Projs/Github Blog/_plugins/debug.rb:8:in `<top (r
equired)>'
from D:/Ruby22/lib/ruby/2.2.0/rubygems/core_ext/kernel_re
quire.rb:54:in `require'
from D:/Ruby22/lib/ruby/2.2.0/rubygems/core_ext/kernel_re
quire.rb:54:in `require'
from D:/Ruby22/lib/ruby/gems/2.2.0/gems/jekyll-3.0.0/lib/
jekyll/plugin_manager.rb:75:in `block (2 levels) in require_plugin_files'
from D:/Ruby22/lib/ruby/gems/2.2.0/gems/jekyll-3.0.0/lib/
jekyll/plugin_manager.rb:74:in `each'
from D:/Ruby22/lib/ruby/gems/2.2.0/gems/jekyll-3.0.0/lib/
jekyll/plugin_manager.rb:74:in `block in require_plugin_files'
from D:/Ruby22/lib/ruby/gems/2.2.0/gems/jekyll-3.0.0/lib/
jekyll/plugin_manager.rb:73:in `each'
from D:/Ruby22/lib/ruby/gems/2.2.0/gems/jekyll-3.0.0/lib/
jekyll/plugin_manager.rb:73:in `require_plugin_files'
from D:/Ruby22/lib/ruby/gems/2.2.0/gems/jekyll-3.0.0/lib/
jekyll/plugin_manager.rb:18:in `conscientious_require'
from D:/Ruby22/lib/ruby/gems/2.2.0/gems/jekyll-3.0.0/lib/
jekyll/site.rb:97:in `setup'
from D:/Ruby22/lib/ruby/gems/2.2.0/gems/jekyll-3.0.0/lib/
jekyll/site.rb:49:in `initialize'
from D:/Ruby22/lib/ruby/gems/2.2.0/gems/jekyll-3.0.0/lib/
jekyll/commands/build.rb:30:in `new'
from D:/Ruby22/lib/ruby/gems/2.2.0/gems/jekyll-3.0.0/lib/
jekyll/commands/build.rb:30:in `process'
from D:/Ruby22/lib/ruby/gems/2.2.0/gems/jekyll-3.0.0/lib/
jekyll/commands/build.rb:18:in `block (2 levels) in init_with_program'
from D:/Ruby22/lib/ruby/gems/2.2.0/gems/mercenary-0.3.5/l
ib/mercenary/command.rb:220:in `call'
from D:/Ruby22/lib/ruby/gems/2.2.0/gems/mercenary-0.3.5/l
ib/mercenary/command.rb:220:in `block in execute'
from D:/Ruby22/lib/ruby/gems/2.2.0/gems/mercenary-0.3.5/l
ib/mercenary/command.rb:220:in `each'
from D:/Ruby22/lib/ruby/gems/2.2.0/gems/mercenary-0.3.5/l
ib/mercenary/command.rb:220:in `execute'
from D:/Ruby22/lib/ruby/gems/2.2.0/gems/mercenary-0.3.5/l
ib/mercenary/program.rb:42:in `go'
from D:/Ruby22/lib/ruby/gems/2.2.0/gems/mercenary-0.3.5/l
ib/mercenary.rb:19:in `program'
from D:/Ruby22/lib/ruby/gems/2.2.0/gems/jekyll-3.0.0/bin/
jekyll:17:in `<top (required)>'
from D:/Ruby22/bin/jekyll:23:in `load'
from D:/Ruby22/bin/jekyll:23:in `<main>'

后来搜了一下官方Github中的Issue,发现了问题所在

相关连接:

原因是我拿V2.X的Proj并且用V3.0的Jekyll来Build了,并且对应的这个post文件夹也变了,因此处理方式就是干脆把所有所有转移到3.0的新Proj算了

所以只需要使用Jekyll建立一个新的Proj

jekyll new MyBlog

就会在当前目录建立一个MyBlog的文件夹,并且里面已经有主要文件了

这个可恶的问题在StackOverFlow找了好久,最终还是官方的Help Doc比较全面

jekyll 3.0.0 | Error: Included file ‘_includes/JB/setup’ not found

这个也是上一个问题的连带问题

V2.X里面的某些Post里面引用了以前的文件,因此现在Not Found是很正常的

D:\Tools_For_Work\Projs\blog>jekyll s
Configuration file: D:/Projs/blog/_config.yml
Source: D:/Projs/blog
   Destination: D:/Projs/blog/_site
 Incremental build: disabled. Enable with --incremental
  Generating...
  Liquid Exception: Included file '_includes/JB/setup' not found in D:/Tools_For
_Work/Projs/blog/_posts/2015-11-11-dicksday.md/#excerpt
jekyll 3.0.0 | Error:  Included file '_includes/JB/setup' not found

解决方法,把以前的Post的格式改成新的格式

错误的文件路径已经显示在Error Msg里面了

cannot load such file – jekyll-paginate (LoadError)

Gem install jekyll-paginate 

就可以了

Dependency Error! It looks like you don’t have redcarpet or one of its

   Dependency Error: Yikes! It looks like you don't have redcarpet or one of its
dependencies installed. In order to use Jekyll as currently configured, you'll n
eed to install this gem. The full error message from Ruby is: 'cannot load such
file -- redcarpet' If you run into trouble, you can find helpful resources at ht
tp://jekyllrb.com/help/!
 ERROR: YOUR SITE COULD NOT BE BUILT:
------------------------------------
redcarpet

一样Gem install 对应的组件就行了

其他问题

一般官方的解答最为有效

https://github.com/jekyll/jekyll/search?utf8=%E2%9C%93&q=&type=Issues

Jekyll.Run

Proj根目录使用jekyll b就可以build

解决了以上问题终于可以build了

D:\Projs\blog>jekyll b
Configuration file: D:/Projs/blog/_config.yml
Source: D:/Projs/blog
   Destination: D:/Projs/blog/_site
 Incremental build: disabled. Enable with --incremental
  Generating...
done in 0.557 seconds.
 Auto-regeneration: disabled. Use --watch to enable.

然后jekyll s开启server,然后使用http://localhost:4000/访问

2015-11-15 Updated

添加分页效果的时候遇到问题

提示说没有安装对应module

Deprecation: You appear to have pagination turned on, but you haven't inc
luded the `jekyll-paginate` gem. Ensure you have `gems: [jekyll-paginate]` in yo
ur configuration file.

使用gem install之后依然报错

原因是没有在Config里面配置本地的Gem,config中加入一行gems声明

gems: [jekyll-paginate]

记得要配置分页细节

paginate: 12
paginate_path: "page:num"

2015-12-11 Error: mapping values are not allowed in this context at line 3 column 18

写新post 的时候遇到问题

Regenerating: 1 file(s) changed at 2015-12-11 21:19:34 Error reading file
D:/Tools_For_Work/Projs/Github Blog/_posts/2015-12-11-wrapstringincf.md: (<unkno
wn>): mapping values are not allowed in this context at line 3 column 18
...error:
    Error: undefined method `each' for nil:NilClass
    Error: Run jekyll build --trace for more information.

跑到那篇文章里找到line 3 column 18发现对应post的title中不能含有分号(:)

删除后解决问题

2016-02-24 Updated

更简单更便捷的Jekyll调试环境搭建: Portable Jekyll-最便捷的JEKYLL安装

2016-09-12 Updated

Coding的Jekyll远程调试环境搭建:Ruby x Jekyll远程调试环境搭建

2016-10-07 Updated

Error: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://api.rubygems.org/latest_specs.4.8.gz)

Win10中初次使用时出现问题, 原因是证书文件缺失

Solution2:

Download the cacert.pem file from http://curl.haxx.se/ca/cacert.pem. Save this file to C:\RailsInstaller\cacert.pem.

Now make ruby aware of your certificate authority bundle by setting SSL_CERT_FILE. To set this in your current command prompt session, type:

set SSL_CERT_FILE=C:\RailsInstaller\cacert.pem To make this a permanent setting, add this in your control panel.

注意要设置到系统变量而不是用户变量

2016-10-07 Error: undefined method `size’ for nil:NilClass (NoMethodError)

gem install时遇到错误

ERROR:  Error installing jekyll:
    invalid gem: package is corrupt, exception while verifying: undefined method `size' for nil:NilClass (NoMethodError)

运行

gem env

然后到GEM PATHS里面删除cache文件夹3

参考文献