“bundle-exec-jekyll-serve”导致 LoadError

1 ruby ruby-on-rails github jekyll

我是一名新手程序员,尝试在我的 Github 博客中使用 Jekyll 主题。这是我第一次使用它......并且我在bundle exec jekyll serve命令方面遇到了问题。(仅供参考,我使用的是 Windows 操作系统。)

这是输出:

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>'
Run Code Online (Sandbox Code Playgroud)

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

1.

bundle add webrick
Run Code Online (Sandbox Code Playgroud)

但有同样的错误

  1. (引用bundle exec jekyllserve:cannot load such file
gem install jekyll github-pages
gem install jekyll
gem install jekyll-feed
bundle update
Run Code Online (Sandbox Code Playgroud)

但有同样的错误

3.

gem install webrick
gem install jekyll -mentions
Run Code Online (Sandbox Code Playgroud)

然后添加

group :jekyll_plugins do
  gem "jekyll-mentions", "1.6.0"
  gem "webrick"
end
Run Code Online (Sandbox Code Playgroud)

到我的 gemfile,然后

bundle install
Run Code Online (Sandbox Code Playgroud)

但有同样的错误

  1. (参考https://github.com/jekyll/jekyll/issues/8523
bundle add sdbm
bundle add webrick
bundle add net-telnet
bundle add xmlrpc
Run Code Online (Sandbox Code Playgroud)

但有同样的错误。

我有什么办法可以解决这种情况吗?

hmd*_*dne 8

据我了解,Ruby 将所有 stdlib 部分移动到 gems 中,有些是“默认 gems”,例如,它们通常与 Ruby 一起安装,不需要在您的 中引用Gemfile,但有些是“捆绑 gems”,它们也已安装使用 Ruby,但需要Gemfile. 问题源于这样一个事实:随着每个 Ruby 版本的发布,一些“默认 gem”变成了“捆绑 gem”。

这样的情况webrick过去也曾发生过。

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

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

bundle add rexml
Run Code Online (Sandbox Code Playgroud)

进而bundle install