"bundle-exec-jekyll-serve" 导致 LoadError

"bundle-exec-jekyll-serve" causes LoadError

我是一名新手程序员,正在尝试为我的 Github 博客使用 Jekyll 主题。这是我第一次使用它...我在使用 bundle exec jekyll serve 命令时遇到了问题。 (仅供参考,我正在使用 Windows OS。)

这是输出:

C:/Ruby30-x64/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 C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/kramdown-1.17.0/lib/kramdown/parser/html.rb:10:in `<top (required)>'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/kramdown-1.17.0/lib/kramdown/parser/kramdown/html.rb:10:in `require'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/kramdown-1.17.0/lib/kramdown/parser/kramdown/html.rb:10:in `<top (required)>'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/kramdown-1.17.0/lib/kramdown/parser/kramdown/paragraph.rb:14:in `require'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/kramdown-1.17.0/lib/kramdown/parser/kramdown/paragraph.rb:14:in `<top (required)>'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/kramdown-1.17.0/lib/kramdown/parser/kramdown.rb:345:in `require'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/kramdown-1.17.0/lib/kramdown/parser/kramdown.rb:345:in `<class:Kramdown>'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/kramdown-1.17.0/lib/kramdown/parser/kramdown.rb:60:in `<module:Parser>'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/kramdown-1.17.0/lib/kramdown/parser/kramdown.rb:19:in `<module:Kramdown>'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/kramdown-1.17.0/lib/kramdown/parser/kramdown.rb:17:in `<top (required)>'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/jekyll-3.8.6/lib/jekyll/converters/smartypants.rb:3:in `require'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/jekyll-3.8.6/lib/jekyll/converters/smartypants.rb:3:in `<top (required)>'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/jekyll-3.8.6/lib/jekyll.rb:13:in `require'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/jekyll-3.8.6/lib/jekyll.rb:13:in `block in require_all'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/jekyll-3.8.6/lib/jekyll.rb:12:in `each'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/jekyll-3.8.6/lib/jekyll.rb:12:in `require_all'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/jekyll-3.8.6/lib/jekyll.rb:194:in `<top (required)>'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/jekyll-3.8.6/exe/jekyll:8:in `require'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/jekyll-3.8.6/exe/jekyll:8:in `<top (required)>'
    from C:/Ruby30-x64/bin/jekyll:25:in `load'
    from C:/Ruby30-x64/bin/jekyll:25:in `<main>'

我尝试了这 4 种不同的解决方案:

1.

bundle add webrick

但是出现同样的错误

  1. (参考
gem install jekyll github-pages
gem install jekyll
gem install jekyll-feed
bundle update

但是出现同样的错误

3.

gem install webrick
gem install jekyll -mentions

然后添加

group :jekyll_plugins do
  gem "jekyll-mentions", "1.6.0"
  gem "webrick"
end

到我的 gemfile,然后

bundle install

但是出现同样的错误

  1. (参考https://github.com/jekyll/jekyll/issues/8523
bundle add sdbm
bundle add webrick
bundle add net-telnet
bundle add xmlrpc

但是出现了同样的错误。

有什么办法可以解决这个问题吗?

据我了解,Ruby 将所有 stdlib 部分移动到 gems,有些是“默认 gems”,因为它们通常与 Ruby 并且在您的 Gemfile 中不需要参考,但有些是“捆绑的 gems”,它们也与 Ruby 一起安装,但需要在 Gemfile 中参考.问题源于一个事实,即每个 Ruby 版本,一些“默认 gems” 变成“捆绑 gems”。

以前webrick就发生过这种情况。

在您的情况下,您很可能需要 rexml,它刚刚成为 Ruby 3.0 中的“捆绑 gem”:https://stdgems.org/rexml/

所有这些都是关于理论的,但解决方案非常简单。你只需要做

bundle add rexml

然后是bundle install.