bundle exec jekyll 服务:无法加载此类文件

问题描述 投票:0回答:8

我正在尝试为 Github Page/Jekyll 站点做出贡献,并希望能够在本地可视化更改,但是当我运行

bundle exec jekyll serve
但我得到以下输出:

bundler: failed to load command: jekyll (/usr/local/lib/ruby/gems/3.0.0/bin/jekyll)
/usr/local/lib/ruby/gems/3.0.0/gems/kramdown-1.17.0/lib/kramdown/parser/html.rb:10:in `require': cannot load such file -- rexml/parsers/baseparser (LoadError)
        from /usr/local/lib/ruby/gems/3.0.0/gems/kramdown-1.17.0/lib/kramdown/parser/html.rb:10:in `<top (required)>'
        from /usr/local/lib/ruby/gems/3.0.0/gems/kramdown-1.17.0/lib/kramdown/parser/kramdown/html.rb:10:in `require'
        from /usr/local/lib/ruby/gems/3.0.0/gems/kramdown-1.17.0/lib/kramdown/parser/kramdown/html.rb:10:in `<top (required)>'
        from /usr/local/lib/ruby/gems/3.0.0/gems/kramdown-1.17.0/lib/kramdown/parser/kramdown/paragraph.rb:14:in `require'
        from /usr/local/lib/ruby/gems/3.0.0/gems/kramdown-1.17.0/lib/kramdown/parser/kramdown/paragraph.rb:14:in `<top (required)>'
        from /usr/local/lib/ruby/gems/3.0.0/gems/kramdown-1.17.0/lib/kramdown/parser/kramdown.rb:345:in `require'
        from /usr/local/lib/ruby/gems/3.0.0/gems/kramdown-1.17.0/lib/kramdown/parser/kramdown.rb:345:in `<class:Kramdown>'
        from /usr/local/lib/ruby/gems/3.0.0/gems/kramdown-1.17.0/lib/kramdown/parser/kramdown.rb:60:in `<module:Parser>'
        from /usr/local/lib/ruby/gems/3.0.0/gems/kramdown-1.17.0/lib/kramdown/parser/kramdown.rb:19:in `<module:Kramdown>'
        from /usr/local/lib/ruby/gems/3.0.0/gems/kramdown-1.17.0/lib/kramdown/parser/kramdown.rb:17:in `<top (required)>'
        from /usr/local/lib/ruby/gems/3.0.0/gems/jekyll-3.8.5/lib/jekyll/converters/smartypants.rb:3:in `require'
        from /usr/local/lib/ruby/gems/3.0.0/gems/jekyll-3.8.5/lib/jekyll/converters/smartypants.rb:3:in `<top (required)>'
        from /usr/local/lib/ruby/gems/3.0.0/gems/jekyll-3.8.5/lib/jekyll.rb:13:in `require'
        from /usr/local/lib/ruby/gems/3.0.0/gems/jekyll-3.8.5/lib/jekyll.rb:13:in `block in require_all'
        from /usr/local/lib/ruby/gems/3.0.0/gems/jekyll-3.8.5/lib/jekyll.rb:12:in `each'
        from /usr/local/lib/ruby/gems/3.0.0/gems/jekyll-3.8.5/lib/jekyll.rb:12:in `require_all'
        from /usr/local/lib/ruby/gems/3.0.0/gems/jekyll-3.8.5/lib/jekyll.rb:194:in `<top (required)>'
        from /usr/local/lib/ruby/gems/3.0.0/gems/jekyll-3.8.5/exe/jekyll:8:in `require'
        from /usr/local/lib/ruby/gems/3.0.0/gems/jekyll-3.8.5/exe/jekyll:8:in `<top (required)>'
        from /usr/local/lib/ruby/gems/3.0.0/bin/jekyll:23:in `load'
        from /usr/local/lib/ruby/gems/3.0.0/bin/jekyll:23:in `<top (required)>'
        from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.2.5/lib/bundler/cli/exec.rb:63:in `load'
        from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.2.5/lib/bundler/cli/exec.rb:63:in `kernel_load'
        from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.2.5/lib/bundler/cli/exec.rb:28:in `run'
        from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.2.5/lib/bundler/cli.rb:494:in `exec'
        from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.2.5/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
        from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.2.5/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
        from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.2.5/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
        from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.2.5/lib/bundler/cli.rb:30:in `dispatch'
        from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.2.5/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
        from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.2.5/lib/bundler/cli.rb:24:in `start'
        from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.2.5/exe/bundle:49:in `block in <top (required)>'
        from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.2.5/lib/bundler/friendly_errors.rb:130:in `with_friendly_errors'
        from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.2.5/exe/bundle:37:in `<top (required)>'
        from /usr/local/opt/ruby/bin/bundle:23:in `load'
        from /usr/local/opt/ruby/bin/bundle:23:in `<main>'

我做了

bundle update
,结果是:

Using concurrent-ruby 1.1.8 (was 1.1.7)
Using multi_json 1.15.0
Using public_suffix 3.1.1
Using latex-decode 0.3.2
Using bundler 2.2.5
Using coffee-script-source 1.11.1
Using execjs 2.7.0
Using colorator 1.1.0
Using namae 1.0.2 (was 1.0.1)
Using unf_ext 0.0.7.7
Using http_parser.rb 0.6.0
Using faraday-net_http 1.0.1
Using multipart-post 2.1.1
Using ruby2_keywords 0.0.4
Using forwardable-extended 2.6.0
Using gemoji 3.0.1
Using rb-fsevent 0.10.4
Using kramdown 1.17.0
Using liquid 4.0.3
Using mercenary 0.3.6
Using rouge 3.13.0
Using safe_yaml 1.0.5
Using racc 1.5.2
Using jekyll-paginate 1.1.0
Using rubyzip 2.3.0
Using jekyll-swiss 1.0.0
Using unicode-display_width 1.7.0
Using i18n 0.9.5
Using coffee-script 2.4.1
Using citeproc 1.0.10
Using csl 1.5.2
Using unf 0.1.4
Using eventmachine 1.2.7
Using citeproc-ruby 1.1.13 (was 1.1.12)
Using activesupport 3.2.22.5
Using csl-styles 1.0.1.10
Using simpleidn 0.2.1 (was 0.1.1)
Using faraday 1.3.0 (was 1.0.1)
Using addressable 2.7.0
Using pathutil 0.16.2
Using jekyll-coffeescript 1.1.1
Using nokogiri 1.11.1 (x86_64-darwin) (was 1.10.10)
Using terminal-table 1.8.0
Using bibtex-ruby 4.4.7
Using em-websocket 0.5.2
Using dnsruby 1.61.5 (was 1.61.4)
Using html-pipeline 2.14.0
Using ffi 1.14.2 (was 1.13.1)
Using sawyer 0.8.2
Using ethon 0.12.0
Fetching ruby-enum 0.9.0 (was 0.8.0)
Using typhoeus 1.4.0
Using octokit 4.20.0 (was 4.18.0)
Using rb-inotify 0.10.1
Using github-pages-health-check 1.16.1
Using sass-listen 4.0.0
Using listen 3.4.1 (was 3.2.1)
Using jekyll-gist 1.5.0
Using sass 3.7.4
Using jekyll-watch 2.2.1
Using jekyll-sass-converter 1.5.2
Using jekyll 3.8.5
Using jekyll-avatar 0.7.0
Using jekyll-github-metadata 2.13.0
Using jekyll-mentions 1.5.1
Using jekyll-optional-front-matter 0.3.2
Using jekyll-readme-index 0.3.0
Using jekyll-redirect-from 0.15.0
Using jekyll-relative-links 0.6.1
Using jekyll-remote-theme 0.4.1
Using jekyll-seo-tag 2.6.1
Using jekyll-sitemap 1.4.0
Using jekyll-titles-from-headings 0.5.3
Using jemoji 0.11.1
Using jekyll-scholar 5.16.0
Using jekyll-feed 0.13.0
Using jekyll-theme-cayman 0.1.1
Using jekyll-theme-dinky 0.1.1
Using jekyll-theme-hacker 0.1.1
Using jekyll-theme-leap-day 0.1.1
Using jekyll-theme-merlot 0.1.1
Using jekyll-default-layout 0.1.4
Using jekyll-theme-minimal 0.1.1
Using jekyll-theme-midnight 0.1.1
Using jekyll-theme-primer 0.5.4
Using jekyll-theme-slate 0.1.1
Using jekyll-theme-tactile 0.1.1
Using jekyll-theme-modernist 0.1.1
Using jekyll-theme-time-machine 0.1.1
Using minima 2.5.1
Using jekyll-theme-architect 0.1.1
Installing ruby-enum 0.9.0 (was 0.8.0)
Using commonmarker 0.17.13
Using jekyll-commonmark 1.3.1
Using jekyll-commonmark-ghpages 0.1.6
Using github-pages 204
Bundle updated!

另外,这是 gemfile 的样子:

source "https://rubygems.org"
gem 'jekyll-scholar', group: :jekyll_plugins

# If you want to use GitHub Pages, remove the "gem "jekyll"" above and
# uncomment the line below. To upgrade, run `bundle update github-pages`.
gem "github-pages", "~> 204", group: :jekyll_plugins

# If you have any plugins, put them here!
group :jekyll_plugins do
  gem "jekyll-feed", "~> 0.6"
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]

# Performance-booster for watching directories on Windows
gem "wdm", "~> 0.1.0" if Gem.win_platform?

为什么不起作用? 我对 ruby 和 jekyll/github 页面相当陌生,但我创建了另一个 Github 页面的网站,并且这个命令没有问题......

ruby rubygems jekyll bundler github-pages
8个回答
56
投票

我遇到了同样的问题,我在这里找到了解决方法https://github.com/jekyll/jekyll/issues/8523

gem "webrick"
添加到您网站的 Gemfile 中。比跑步
bundle install

此时就可以运行了

bundle exec jekyll serve

对我来说它有效!


17
投票

我也遇到这个错误。解决方案位于文档本身

如果您使用的是 Ruby 版本3.0.0 或更高版本,步骤 5 可能会失败(

bundle exec jekyll serve
)。您可以通过将
webrick
添加到您的依赖项来修复它:
bundle add webrick

或将

gem "webrick"
添加到
Gemfile
中,然后添加
bundle install


14
投票

这就是我解决这个问题的方法,感谢@choas的评论:

  1. 通过运行
    gem install github-pages
    gem install jekyll
    gem install jekyll-feed
    更新了 github-pages、jekyll 和 jekyll-feed gems。我必须执行此步骤,因为简单的
    bundle update
    没有安装最新版本。
  2. 将 Gemfile 中的那些 gem 修改为最新版本。
  3. 奔跑
    bundle update
  4. 终于跑了
    bundle exec jekyll serve

我不确定所有这些步骤是否多余,因为我对 Ruby/Github Pages/Jekyll 不太熟悉,但它确实有效。


8
投票

我发现您正在使用

github-pages:204
jekyll:3.8.5

我使我的项目具有相同的依赖项:

  1. bundle update github-pages
  2. bundle add webrick

4
投票
  1. 安装 webrick 和 jekyll-mentions:打开终端并输入
    gem install webrick
    ,然后输入
    gem install jekyll-mentions
  2. 打开你的gem文件并在pulgins中添加gem“jekyll-mentions”和gem“webrick”:
group :jekyll_plugins do
  gem "jekyll-mentions", "1.6.0"
  gem "webrick"
end
  1. 导航回终端,然后执行
    bundle install

我想你可以走了。这个过程对我有用!


4
投票

只需删除 gemfile 中 jekyll 的特定版本,因为该特定性会导致 kramdown 包出现依赖问题。

gem "jekyll", "~> 3.2.1"

删除特定版本的 jekyll,如下所示:

gem "jekyll"

将 webrick gem 添加到 gemfile

gem "webrick"

再次运行捆绑程序。

bundler

最后上菜吧

bundle exec jekyll serve --livereload

1
投票

感谢您最密切的帮助我的工作。我显然还需要一堆其他插件,所以我的工作 Gemfile jekyll_plugins 看起来像这样:

group :jekyll_plugins do
  gem "jekyll-feed"
  gem "jekyll-mentions"
  gem "webrick"
  gem "jekyll-redirect-from"
  gem "jekyll-sitemap"
  gem "jekyll-avatar"
  gem "jemoji"
end

然后

bundle install; bundle exec jekyll serve


0
投票

安装了 gem,但看到

bundle exec
抱怨它丢失似乎是一件相当罕见的事情。虽然我的问题是关于不同的应用程序(乘客),但这是我发现的关于该主题的最佳线程。我在这里发布我的解决方案,以便其他人可以找到它。

我的应用程序抱怨缺少库,尽管它在使用

bundle exec <app>
启动时确实已安装。

我发现需要在我运行bundle-command的目录中的

Gemfile
中提及该库。

在我的设置中,我有两个 ruby 项目:一个 REST 接口(sinatra/passenger)和一个包含业务逻辑的自定义库。这两个项目都有自己的 Gemfile。相关库由业务逻辑使用,因此它位于 Gemfile 中。由于某种原因,起始乘客会因抱怨图书馆丢失而崩溃。

在我将该库添加到两个项目的 Gemfile 中后,问题才消失。

© www.soinside.com 2019 - 2024. All rights reserved.