雨果与 asciidoctor 坏了 "can't find gem asciidoctor"

Hugo with asciidoctor broken "can't find gem asciidoctor"

我有一个使用 Hugo 和 Asciidoctor 的现有博客,但是 运行 hugo server 开始失败。我首先添加了额外的安全配置,如 .

中所述

但仍然无法正常工作,我收到此错误:

ERROR 2022/02/19 17:11:36 blog/2021/12/23/Taming Thymeleaf 2.0 release.adoc: /Users/wdb/.rvm/rubies/ruby-2.7.0/lib/ruby/site_ruby/2.7.0/rubygems.rb:277:in `find_spec_for_exe': can't find gem asciidoctor (>= 0.a) with executable asciidoctor (Gem::GemNotFoundException)
ERROR 2022/02/19 17:11:36 blog/2021/12/23/Taming Thymeleaf 2.0 release.adoc: from /Users/wdb/.rvm/rubies/ruby-2.7.0/lib/ruby/site_ruby/2.7.0/rubygems.rb:296:in `activate_bin_path'
ERROR 2022/02/19 17:11:36 blog/2021/12/23/Taming Thymeleaf 2.0 release.adoc: from /Users/wdb/.rvm/gems/ruby-2.7.0/bin/asciidoctor:23:in `<main>'
ERROR 2022/02/19 17:11:36 blog/2021/12/23/Taming Thymeleaf 2.0 release.adoc: from /Users/wdb/.rvm/gems/ruby-2.7.0/bin/ruby_executable_hooks:24:in `eval'
ERROR 2022/02/19 17:11:36 blog/2021/12/23/Taming Thymeleaf 2.0 release.adoc: from /Users/wdb/.rvm/gems/ruby-2.7.0/bin/ruby_executable_hooks:24:in `<main>'
ERROR 2022/02/19 17:11:36 asciidoctor rendering blog/2021/12/23/Taming Thymeleaf 2.0 release.adoc: failed to execute binary "asciidoctor" with args [--no-header-footer -]: /Users/wdb/.rvm/rubies/ruby-2.7.0/lib/ruby/site_ruby/2.7.0/rubygems.rb:277:in `find_spec_for_exe': can't find gem asciidoctor (>= 0.a) with executable asciidoctor (Gem::GemNotFoundException)
    from /Users/wdb/.rvm/rubies/ruby-2.7.0/lib/ruby/site_ruby/2.7.0/rubygems.rb:296:in `activate_bin_path'
    from /Users/wdb/.rvm/gems/ruby-2.7.0/bin/asciidoctor:23:in `<main>'
    from /Users/wdb/.rvm/gems/ruby-2.7.0/bin/ruby_executable_hooks:24:in `eval'
    from /Users/wdb/.rvm/gems/ruby-2.7.0/bin/ruby_executable_hooks:24:in `<main>'

我正在使用:

我有一个 Gemfile 这样的:

source 'https://rubygems.org'
gem 'asciidoctor'
gem 'rouge'

Gemfile.lock:

GEM
  remote: https://rubygems.org/
  specs:
    asciidoctor (2.0.17)
    rouge (3.28.0)

PLATFORMS
  ruby

DEPENDENCIES
  asciidoctor
  rouge

BUNDLED WITH
   2.1.4

如果您需要任何其他帮助我调试它,请告诉我。

更新:

我 运行 rvm install ruby 2.7.5 安装 Ruby 2.7.5 现在我得到这个错误 运行 hugo server:

WARN 2022/02/20 10:47:43 blog/2021/12/23/Taming Thymeleaf 2.0 release.adoc: Ignoring ffi-1.11.3 because its extensions are not built. Try: gem pristine ffi --version 1.11.3

我运行gem install ffi --version='1.11.3'gem pristine ffi --version 1.11.3,还是一样的错误信息。

我使用 https://rvm.io/support/troubleshooting.

中的命令从我的系统中完全删除了 RVM,设法让它再次工作

实际上,这是预期的行为。 Starting from the version 0.91 Hugo filters out the environment for child processes according to some regex. So the issue is simple: GEM_PATH (or GEM_HOME) is filtered out. Read more in this ticket.

要修复它,只需将 config.yaml (config.toml) 中的 GEM_PATH 变量列入白名单即可:

security:
  exec:
    osEnv:
      - (?i)^(PATH|PATHEXT|APPDATA|TMP|TEMP|TERM|GEM_PATH)$ # Note this GEM_PATH
    allow:
      - asciidoctor                                         # Don't forget to whitelist Asciidoctor as well