微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决在本地启动 GitHub 页面 Jekyll 页面时出错

我正在使用 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,遗憾的是这不适用于 last 4.2 jekyll 版本 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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。