在本地启动 GitHub 页面时出错 Jekyll 页面

Error while locally launching GitHub pages Jekyll page

我正在使用 Jekyll 构建一个 GitHub 页的网站。我想在本地 运行 这个网站,但不幸的是我有很多错误。

我正在运行使用此命令在本地主机上启动我的网站

我遵循了这个教程:https://docs.github.com/en/pages/setting-up-a-github-pages-site-with-jekyll/about-github-pages-and-jekyll

bundle exec jekyll serve

这些是我得到的错误:

$ bundle exec jekyll serve --incremental
                    done in 0.376 seconds.
 Auto-regeneration: enabled for 'D:/melmasset.github.io'
C:/Ruby30/lib/ruby/gems/3.0.0/gems/jekyll-3.9.0/lib/jekyll/commands/serve/servlet.rb:3:in `require': cannot load such file -- webrick (LoadError)
        from C:/Ruby30/lib/ruby/gems/3.0.0/gems/jekyll-3.9.0/lib/jekyll/commands/serve/servlet.rb:3:in `<top (required)>'
        from C:/Ruby30/lib/ruby/gems/3.0.0/gems/jekyll-3.9.0/lib/jekyll/commands/serve.rb:184:in `require_relative'
        from C:/Ruby30/lib/ruby/gems/3.0.0/gems/jekyll-3.9.0/lib/jekyll/commands/serve.rb:184:in `setup'
        from C:/Ruby30/lib/ruby/gems/3.0.0/gems/jekyll-3.9.0/lib/jekyll/commands/serve.rb:102:in `process'
        from C:/Ruby30/lib/ruby/gems/3.0.0/gems/jekyll-3.9.0/lib/jekyll/commands/serve.rb:93:in `block in start'
        from C:/Ruby30/lib/ruby/gems/3.0.0/gems/jekyll-3.9.0/lib/jekyll/commands/serve.rb:93:in `each'
        from C:/Ruby30/lib/ruby/gems/3.0.0/gems/jekyll-3.9.0/lib/jekyll/commands/serve.rb:93:in `start'
        from C:/Ruby30/lib/ruby/gems/3.0.0/gems/jekyll-3.9.0/lib/jekyll/commands/serve.rb:75:in `block (2 levels) in init_with_program'
        from C:/Ruby30/lib/ruby/gems/3.0.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `block in execute'
        from C:/Ruby30/lib/ruby/gems/3.0.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `each'
        from C:/Ruby30/lib/ruby/gems/3.0.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `execute'
        from C:/Ruby30/lib/ruby/gems/3.0.0/gems/mercenary-0.3.6/lib/mercenary/program.rb:42:in `go'
        from C:/Ruby30/lib/ruby/gems/3.0.0/gems/mercenary-0.3.6/lib/mercenary.rb:19:in `program'
        from C:/Ruby30/lib/ruby/gems/3.0.0/gems/jekyll-3.9.0/exe/jekyll:15:in `<top (required)>'
        from C:/Ruby30/bin/jekyll:23:in `load'
        from C:/Ruby30/bin/jekyll:23:in `<main>'

问我是否需要其他适应症:)

这是一个已知问题 with ruby 3 not having webrick by default anymore
好消息是 the issue has already been fixed, sadly this isn't available for last 4.2 jekyll version, only in master,所以您的选择是:

  • 使用 bundle add webrick

    将 webrick 添加到您的项目包中
  • 手动安装 gem,进行最后的更改,使用:

git clone https://github.com/jekyll/jekyll.git
cd jekyll
gem build jekyll.gemspec
gem install jekyll-4.2.0.gem
  • 降级到 ruby 2.7