簡體   English   中英

Jekyll / Ruby Kramdown缺少依賴性

[英]Jekyll/Ruby Kramdown Missing Dependency

我正在努力設置我的第一個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的新手,所以任何幫助都會非常感激!

我認為問題是

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的可執行文件可能會有效。 然而,這是不可靠的,並且是相當痛苦的根源。 即使看起來它有效,它可能在將來或在另一台機器上不起作用。

這很可能是因為安裝了多個jekyll寶石。 Jekyll可以多次安裝,因為可能有

  1. 首次嘗試通過gem install jekyll安裝它
  2. 根據指南的建議在Gemfile中添加了github-pages依賴項

因此,您應該檢查是否有多個已安裝的副本。 從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。

刪除Gemfile.lock

bundle install

跑傑基爾

我在我的環境中解決了同樣的問題:

$>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

希望這可以幫助。

我在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)

重啟你的shell

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)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM