【问题标题】:Jekyll build failed: Liquid Exception: cannot load such file -- yajlJekyll 构建失败:Liquid 异常:无法加载此类文件 -- yajl
【发布时间】:2013-12-25 05:43:58
【问题描述】:

最近刚刚弄坏了我的电脑,我已经有一段时间没有使用 Jekyll,或者确实没有使用过 Ruby,但是在我认为我已经正确设置了所有东西之后,当我尝试运行时......

jekyll 构建或 杰基尔发球

我收到此错误:

Generating...   Liquid Exception: cannot load such file -- yajl/2.0/yajl i
n _posts/2013-09-21-welcome-to-jekyll.markdown
C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:53:in `require': c
annot load such file -- yajl/2.0/yajl (LoadError)
        from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:53:in
 `require'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/yajl-ruby-1.1.0-x86-mingw32/lib
/yajl/yajl.rb:2:in `<top (required)>'
        from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:53:in
 `require'
        from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:53:in
 `require'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/yajl-ruby-1.1.0-x86-mingw32/lib
/yajl.rb:1:in `<top (required)>'
        from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:118:i
n `require'
        from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:118:i
n `rescue in require'
        from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:124:i
n `require'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/pygments.rb-0.5.4/lib/pygments/
popen.rb:3:in `<top (required)>'
        from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:114:i
n `require'
        from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:114:i
n `require'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/pygments.rb-0.5.4/lib/pygments.
rb:1:in `<top (required)>'
        from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:66:in
 `require'
        from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:66:in
 `require'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/jekyll-1.3.1/lib/jekyll/tags/hi
ghlight.rb:52:in `render_pygments'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/jekyll-1.3.1/lib/jekyll/tags/hi
ghlight.rb:45:in `render'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/liquid-2.5.4/lib/liquid/block.r
b:106:in `block in render_all'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/liquid-2.5.4/lib/liquid/block.r
b:93:in `each'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/liquid-2.5.4/lib/liquid/block.r
b:93:in `render_all'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/liquid-2.5.4/lib/liquid/block.r
b:82:in `render'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/liquid-2.5.4/lib/liquid/templat
e.rb:124:in `render'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/liquid-2.5.4/lib/liquid/templat
e.rb:132:in `render!'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/jekyll-1.3.1/lib/jekyll/convert
ible.rb:88:in `render_liquid'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/jekyll-1.3.1/lib/jekyll/convert
ible.rb:150:in `do_layout'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/jekyll-1.3.1/lib/jekyll/post.rb
:259:in `render'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/jekyll-1.3.1/lib/jekyll/site.rb
:241:in `block in render'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/jekyll-1.3.1/lib/jekyll/site.rb
:240:in `each'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/jekyll-1.3.1/lib/jekyll/site.rb
:240:in `render'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/jekyll-1.3.1/lib/jekyll/site.rb
:39:in `process'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/jekyll-1.3.1/lib/jekyll/command
.rb:18:in `process_site'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/jekyll-1.3.1/lib/jekyll/command
s/build.rb:23:in `build'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/jekyll-1.3.1/lib/jekyll/command
s/build.rb:7:in `process'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/jekyll-1.3.1/bin/jekyll:77:in `
block (2 levels) in <top (required)>'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/commander-4.1.5/lib/commander/c
ommand.rb:180:in `call'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/commander-4.1.5/lib/commander/c
ommand.rb:180:in `call'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/commander-4.1.5/lib/commander/c
ommand.rb:155:in `run'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/commander-4.1.5/lib/commander/r
unner.rb:402:in `run_active_command'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/commander-4.1.5/lib/commander/r
unner.rb:66:in `run!'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/commander-4.1.5/lib/commander/d
elegates.rb:7:in `run!'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/commander-4.1.5/lib/commander/i
mport.rb:10:in `block in <top (required)>'

我认为它以某种方式与 pygments.rb 有关。如果我删除第一个具有语法高亮演示的帖子,则构建工作。我试图将 pgyments 更新到 0.5.4 但这似乎没有什么不同。我认为 pygments.rb 被锁定到 0.3.4 的错误:

Fetching gem metadata from https://rubygems.org/.......
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
You have requested:
  pygments.rb ~> 0.5.4

The bundle currently has pygments.rb locked at 0.3.7.
Try running `bundle update pygments.rb`

任何人都可以对此有所了解吗?它快把我逼疯了。运行 Ruby 2.0.0p353。

【问题讨论】:

  • 你跑bundle了吗?或者尝试gem install yajl?
  • 是的,yajl 失败,因为它说:错误:在任何存储库中找不到有效的 gem 'yajl' (>= 0)

标签: ruby gem jekyll


【解决方案1】:

我今天在尝试设置 Octopress/Jekyll 时遇到了类似的问题。

这是我找到的解决方案。

第 1 步

转到您的 ruby​​ gems 目录。 就我而言,它位于C:/Ruby21/lib/ruby/gems/2.1.0/gems

寻找 yajl。

您将看到一个名为yajl-ruby-1.1.0-x86-mingw32的文件夹

你可能会也可能不会看到一个叫yajl-ruby-1.2.1的人

带有 -ruby-1.1.0-x86-mingw32 尾巴的是默认的。并导致错误。

我们要使用的是其他版本

第 2 步

如果您没有 none mingw32 版本,请运行

gem install yajl-ruby

这将安装最新版本。

就我而言,最新版本是 1.2.1

第 3 步

将默认从 mingw32 版本更改为当前版本。

为此,请转到您网站的gemfile.lock 文件

找到写着yajl-ruby (1.1.0-x86-mingw32)的那一行

并将其更改为yajl-ruby (1.2.1)

或您下载的相应版本

第 4 步

就是这样。它现在应该可以工作了。

【讨论】:

    【解决方案2】:

    我关注了

    gem install rouge
    

    然后 在 _config.yml

    中添加了以下行
    highlighter: rouge
    

    我从以下页面的最后一条评论中找到了这个解决方案 https://github.com/jekyll/jekyll-help/issues/50

    【讨论】:

      【解决方案3】:

      Yajl 本身是一个“用 ANSI C 编写的小型事件驱动(SAX 风格)JSON 解析器。”您应该将它安装在您的 Windows 机器上(我不确定是否有可用的二进制下载,可能您要下载源代码并使用您首选的 C 编译器编译它们)在尝试之前安装yajl-ruby gem,就是简单的绑定到它。

      另一种选择是安装Ruby开发包,详细解释请参考this manual。

      【讨论】:

      • 我已经安装了 devkit,但它并没有解决我的问题
      • 我多年没有接触过windows,但是如果是&lt;= 2.0,你会尝试打电话给yajl --version并从源代码安装yajl吗?
      • @Mat-visual 还有,顺便说一句,yajl-ruby gem 安装扩展没有问题吗?
      猜你喜欢
      • 2019-05-29
      • 1970-01-01
      • 2015-01-27
      • 1970-01-01
      • 2020-07-31
      • 2012-09-25
      • 2018-11-12
      • 2019-11-20
      相关资源
      最近更新 更多