首页 > 解决方案 > Jekyll 和 Nokogiri 安装问题

问题描述

我在 Windows 上使用 ubuntu 18.04.2 LTS,我有一个基本问题。我的目标是使用 github 模板https://github.com/github/personal-website并将其发布到username.github.io

我对第 4 步有疑问:

构建站点并使其在本地服务器上可用

bundle exec jekyll serve
hafidz@LAMBDA05:~/personal-website$ bundle exec jekyll serve
**Could not find nokogiri-1.10.1 in any of the sources**
Run `bundle install` to install missing gems.

安装 bundle、jekyll 和 nokogori 已经是一种解决方法,但我认为已经完成了。需要路径设置吗?

hafidz@LAMBDA05:~/personal-website$ bundle -v
Bundler version 2.0.1
hafidz@LAMBDA05:~/personal-website$ jekyll -v
Traceback (most recent call last):
        12: from /usr/local/bin/jekyll:23:in `<main>'
        11: from /usr/local/bin/jekyll:23:in `load'
        10: from /var/lib/gems/2.5.0/gems/jekyll-3.8.5/exe/jekyll:11:in `<top (required)>'
         9: from /var/lib/gems/2.5.0/gems/jekyll-3.8.5/lib/jekyll/plugin_manager.rb:50:in `require_from_bundler'
         8: from /var/lib/gems/2.5.0/gems/bundler-2.0.1/lib/bundler.rb:107:in `setup'
         7: from /var/lib/gems/2.5.0/gems/bundler-2.0.1/lib/bundler/runtime.rb:20:in `setup'
         6: from /var/lib/gems/2.5.0/gems/bundler-2.0.1/lib/bundler/runtime.rb:108:in `block in definition_method'
         5: from /var/lib/gems/2.5.0/gems/bundler-2.0.1/lib/bundler/definition.rb:226:in `requested_specs'
         4: from /var/lib/gems/2.5.0/gems/bundler-2.0.1/lib/bundler/definition.rb:237:in `specs_for'
         3: from /var/lib/gems/2.5.0/gems/bundler-2.0.1/lib/bundler/definition.rb:170:in `specs'
         2: from /var/lib/gems/2.5.0/gems/bundler-2.0.1/lib/bundler/spec_set.rb:81:in `materialize'
         1: from /var/lib/gems/2.5.0/gems/bundler-2.0.1/lib/bundler/spec_set.rb:81:in `map!'
/var/lib/gems/2.5.0/gems/bundler-2.0.1/lib/bundler/spec_set.rb:87:in `block in materialize': Could not find nokogiri-1.10.1 in any of the sources (Bundler::GemNotFound)
hafidz@LAMBDA05:~/personal-website$ nokogiri -v
# Nokogiri (1.10.1)
    ---
    warnings: []
    nokogiri: 1.10.1
    ruby:
      version: 2.5.3
      platform: x86_64-linux-gnu
      description: ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux-gnu]
      engine: ruby
    libxml:
      binding: extension
      source: packaged
      libxml2_path: "/var/lib/gems/2.5.0/gems/nokogiri-1.10.1/ports/x86_64-pc-linux-gnu/libxml2/2.9.9"
      libxslt_path: "/var/lib/gems/2.5.0/gems/nokogiri-1.10.1/ports/x86_64-pc-linux-gnu/libxslt/1.1.33"
      libxml2_patches:
      - 0001-Revert-Do-not-URI-escape-in-server-side-includes.patch
      libxslt_patches: []
      compiled: 2.9.9
      loaded: 2.9.9

感谢帮助

标签: rubyubuntunokogiri

解决方案


我在使用 Ubuntu WSL 时看到了类似的东西。我一直在遵循 Jekyll WSL 的说明并被卡住了。Dave Rupert 的博客(链接)上有一个很好的提示,它推荐了以下内容并解除了对我的阻止:apt install zlibc zlib1g-dev libxml2 libxml2-dev libxslt1.1 libxslt1-dev

这是我的 bash 会话历史转储:

   24  sudo apt install ruby
   26  gem update jekyll
   27  code .
   28  sudo apt-get update -y && sudo apt-get upgrade -y
   30  sudo gem update
   31  sudo apt-add-repository ppa:brightbox/ruby-ng
   32  sudo apt-get update
   33  sudo apt-get install ruby2.5 ruby2.5-dev build-essential dh-autoreconf
   35  sudo gem update
   37  sudo gem install jekyll bundler
   38  jekyll -v
   40  sudo bundle update
   45  sudo bundle install
   47  sudo apt install zlibc zlib1g-dev libxml2 libxml2-dev libxslt1.1 libxslt1-dev
   48  sudo gem install nokogiri -v '1.8.2' --source 'https://rubygems.org/'
   49  sudo bundle install
   51  bundle exec jekyll -v
   52  bundle exec jekyll serve
   54  sudo bundle update
   56  bundle exec jekyll serve
   57  history
   58  history > history.txt

推荐阅读