17

我正在努力建立我的第一个 jekyll 博客。我正在尝试运行 jekyll 服务器,但是在将其输入终端后,我收到了错误消息:

You are missing a library required for Markdown. Please run:
$ [sudo] gem install kramdown
Conversion error: Jekyll::Converters::Markdown encountered an error while converting '_posts/2013-08-15-immunize-canada-app.md/#excerpt':
                Missing dependency: kramdown
         ERROR: YOUR SITE COULD NOT BE BUILT:
                ------------------------------------
                Missing dependency: kramdown

我已经按照要求安装了 kramdown,但仍然收到此错误。我在另一篇文章中发现将 gem 'kramdown' 添加到 Gemfile,但仍然无法正常工作。我是 Ruby/Jekyll 的超级新手,所以非常感谢任何帮助!

4

5 回答 5

47

我认为问题是

gem query | grep kramdown
kramdown (1.8.0, 1.5.0)

bundle show kramdown
/Library/Ruby/Gems/2.0.0/gems/kramdown-1.5.0

如http://bundler.io/中所建议,始终使用bundle exec

bundle exec jekyll serve --watch 

在某些情况下,如果可执行文件恰好安装在您的系统中并且没有拉入任何与您的捆绑包冲突的 gem,则在没有 bundle exec 的情况下运行可执行文件可能会起作用。然而,这是不可靠的并且是相当大的痛苦的来源。即使它看起来可以正常工作,但将来或在另一台机器上可能无法正常工作。

于 2015-08-26T18:22:55.333 回答
12

这很可能是由于安装了多个jekyllgem。Jekyll 可以安装多次,因为一个可能有

  1. gem install jekyll第一次尝试安装它
  2. github-pages按照指南的建议在 Gemfile 中添加了依赖项

因此,您应该检查是否有多个已安装的副本。从 shell运行gem list jekyll,输出以下内容:

$ gem list jekyll

*** LOCAL GEMS ***

jekyll (2.5.3, 2.4.0)
jekyll-coffeescript (1.0.1)
jekyll-feed (0.3.1)
jekyll-gist (1.3.4, 1.2.1)
...

如您所见,安装了 2.5.3 和 2.4.0。我跑去gem uninstall摆脱一个。旧版本是 的依赖github-pages,因此只需卸载即可jekyll-2.5.3

$ gem uninstall jekyll

Select gem to uninstall:
 1. jekyll-2.4.0
 2. jekyll-2.5.3
 3. All versions
> 2
Successfully uninstalled jekyll-2.5.3

我也jekyll-gist用同样的方法卸载了。这样你根本不需要卸载 ruby​​。

于 2015-09-10T06:34:11.793 回答
3

删除Gemfile.lock

bundle install

运行 jekyll

于 2015-09-16T11:57:15.433 回答
2

我在我的环境中解决了同样的问题:

$>gem uninstall kramdown

Select gem to uninstall:
 1. kramdown-1.5.0
 2. kramdown-1.9.0
 3. All versions
> 3

You have requested to uninstall the gem:
        kramdown-1.5.0

github-pages-39 depends on kramdown (= 1.5.0)
If you remove this gem, these dependencies will not be met.
Continue with Uninstall? [yN]  y
Successfully uninstalled kramdown-1.5.0

You have requested to uninstall the gem:
        kramdown-1.9.0

jekyll-3.0.1 depends on kramdown (~> 1.3)
jekyll-2.4.0 depends on kramdown (~> 1.3)
markdown-1.2.0 depends on kramdown (>= 1.5.0)
test-unit-3.1.5 depends on kramdown (>= 0, development)
If you remove this gem, these dependencies will not be met.
Continue with Uninstall? [yN]  y
Remove executables:
        kramdown

in addition to the gem? [Yn]  y
Removing kramdown
Successfully uninstalled kramdown-1.9.0

$>gem install kramdown
Fetching: kramdown-1.9.0.gem (100%)
Successfully installed kramdown-1.9.0
Parsing documentation for kramdown-1.9.0
Installing ri documentation for kramdown-1.9.0
Done installing documentation for kramdown after 2 seconds
1 gem installed

该问题是由 2 个版本的kramdown.

所以uninstall先做,然后再做install

希望这可以帮助。

于 2015-11-23T16:05:57.030 回答
0

我在 OS X Yosemite 下遇到了同样的问题,你应该检查你的 Ruby 环境,看看bundle install命令是否将你的 gem 安装到正确的位置。

which ruby
which gem
which jekyll
bundle show jekyll

你可能会发现你没有调用jekyll你想要的权利。


我的解决方案:

brew uninstall ruby (I installed ruby with HomeBrew) brew install rbenv ruby-build (Use rbenv to manage system Ruby reference) echo 'eval "$(rbenv init -)"' >> ~/.bash_profile (or ~/.zshrc)

重新启动你的外壳

rbenv install 2.2.2 (Install Ruby v2.2.2) rbenv global 2.2.2 (Make v2.2.2 the global default) rbenv versions (Double check the output, whether the default is not system one)

于 2015-07-28T07:29:35.160 回答