ruby bundle exec jekyll serve:无法加载此类文件

vfh0ocws  于 2023-10-17  发布在  Ruby
关注(0)|答案(8)|浏览(157)

我试图为Github页面/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!

这就是gem文件的样子:

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页面的网站,这个命令没有问题。

qyswt5oh

qyswt5oh1#

我也遇到了同样的问题,我在https://github.com/jekyll/jekyll/issues/8523找到了一个解决方案
gem "webrick"添加到您网站的Gemfile中。运行bundle install
此时可以运行bundle exec jekyll serve
对我来说,它工作!

kdfy810k

kdfy810k2#

我也犯了这个错误。解决方案在documentation itself中。
如果您使用的是Ruby版本3.0.0或更高版本,则步骤5可能会失败bundle exec jekyll serve)。您可以通过将webrick添加到您的依赖项来修复它:bundle add webrick
或者将gem "webrick"添加到Gemfile中,然后添加bundle install

pxq42qpu

pxq42qpu3#

以下是我如何解决它感谢@choas的评论:
1.通过运行gem install github-pagesgem install jekyllgem install jekyll-feed更新了github-pages、jekyll和jekyll-feed gems。我不得不做这一步,因为一个简单的bundle update没有安装最新版本。
1.将Gemfile中的gem修改为最新版本。
1.运行bundle update
1.运行bundle exec jekyll serve
我不确定所有这些步骤是否多余,因为我对Ruby/Github Pages/Jekyll不是很熟悉,但它确实有效。

jucafojl

jucafojl4#

我看到你正在使用github-pages:204jekyll:3.8.5
我让我的项目具有相同的依赖关系:

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

vddsk6oq5#

1.安装webrick和jekyll-mentions:打开终端,输入gem install webrick,然后输入gem install jekyll-mentions
1.打开你的gem文件,在pulgins中添加gem“jekyll-mentions”和gem“webrick”:

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

1.导航回终端,然后执行bundle install
你可以走了,我想。这个过程为我工作!

wgxvkvu9

wgxvkvu96#

简单地删除gemfile中的特定版本的jekyll,因为这种特殊性会导致kramdown包的依赖性问题。

gem "jekyll", "~> 3.2.1"

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

gem "jekyll"

将webrick gem添加到gemfile

gem "webrick"

再查一遍。

bundler

最后,服务

bundle exec jekyll serve --livereload
bf1o4zei

bf1o4zei7#

谢谢你,你最接近我的工作。我显然还需要一堆其他插件,所以我的工作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

iqjalb3h

iqjalb3h8#

安装了一个gem,但看到bundle exec抱怨它丢失似乎是一件相当罕见的事情。虽然我的问题是关于一个不同的应用程序(乘客),这是我发现的关于这个主题的最好的线程。我把我的解决方案发布在这里,这样其他人就可以找到它。
我让我的应用程序抱怨缺少一个库,尽管它肯定是安装的,当用bundle exec <app>启动时。
我发现这个库需要在我运行的目录中的Gemfile中提到。
在我的设置中,我有两个ruby项目:一个REST接口(sinatra/passenger)和一个包含业务逻辑的自定义库。这两个项目都有自己的Gemfile。相关库由业务逻辑使用,因此它在Gemfile中。出于某种原因,首发乘客会因为抱怨图书馆不见了而撞车。
在我把这个库添加到两个项目的Gemfile中之后,这个问题就消失了。

相关问题