asciidoctor / asciidoctor-pdf

:page_with_curl: Asciidoctor PDF: A native PDF converter for AsciiDoc based on Asciidoctor and Prawn, written entirely in Ruby.
https://docs.asciidoctor.org/pdf-converter/latest/
MIT License
1.14k stars 501 forks source link

"undefined method `absolute_path?' " #2418

Closed jnk0le closed 1 year ago

jnk0le commented 1 year ago

I have previously working workflow that suddenly started throwing errors in asciidoctor step.

https://github.com/jnk0le/XTightlyCoupledIO/commit/687f4fe64f4c546a549fc1c9918a3c3983e2f7d7

Run PATH=${PATH}:${BUNDLE_BIN}:$(npm bin) \
  PATH=${PATH}:${BUNDLE_BIN}:$(npm bin) \
  make ${PDF_RESULT}
  shell: /usr/bin/bash -e {0}
  env:
    APT_PACKAGES_FILE: /home/runner/work/XTightlyCoupledIO/XTightlyCoupledIO/dependencies/apt_packages.txt
    BUNDLE_GEMFILE: /home/runner/work/XTightlyCoupledIO/XTightlyCoupledIO/dependencies/Gemfile
    BUNDLE_BIN: /home/runner/work/XTightlyCoupledIO/XTightlyCoupledIO/bin
    NPM_PACKAGE_FOLDER: /home/runner/work/XTightlyCoupledIO/XTightlyCoupledIO/dependencies
    PDF_RESULT: XTightlyCoupledIO.pdf
asciidoctor-pdf \
-a compress \
--require=asciidoctor-diagram \
--out-file=XTightlyCoupledIO.pdf \
xtightlycoupledio.adoc
undefined method `absolute_path?' for File:Class
Did you mean?  absolute_path
  Use --trace to show backtrace
make: *** [Makefile:10: XTightlyCoupledIO.pdf] Error 1
Error: Process completed with exit code 2.

and with trace (different repo)

Run PATH=${PATH}:${BUNDLE_BIN}:$(npm bin) \
  PATH=${PATH}:${BUNDLE_BIN}:$(npm bin) \
  make ${PDF_RESULT}
  shell: /usr/bin/bash -e {0}
  env:
    APT_PACKAGES_FILE: /home/runner/work/riscv-total-embedded/riscv-total-embedded/dependencies/apt_packages.txt
    BUNDLE_GEMFILE: /home/runner/work/riscv-total-embedded/riscv-total-embedded/dependencies/Gemfile
    BUNDLE_BIN: /home/runner/work/riscv-total-embedded/riscv-total-embedded/bin
    NPM_PACKAGE_FOLDER: /home/runner/work/riscv-total-embedded/riscv-total-embedded/dependencies
    PDF_RESULT: riscv-total-embedded.pdf
asciidoctor-pdf \
-a compress \
--require=asciidoctor-diagram \
--out-file=riscv-total-embedded.pdf \
--trace \
riscv-total-embedded.adoc
/home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-pdf-2.3.6/lib/asciidoctor/pdf/converter.rb:4290:in `resolve_image_path': undefined method `absolute_path?' for File:Class (NoMethodError)
Did you mean?  absolute_path
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-pdf-2.3.6/lib/asciidoctor/pdf/converter.rb:1715:in `convert_image'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-pdf-2.3.6/lib/asciidoctor/pdf/converter.rb:152:in `convert'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-2.0.18/lib/asciidoctor/abstract_block.rb:75:in `convert'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-2.0.18/lib/asciidoctor/abstract_block.rb:84:in `block in content'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-2.0.18/lib/asciidoctor/abstract_block.rb:84:in `map'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-2.0.18/lib/asciidoctor/abstract_block.rb:84:in `content'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-pdf-2.3.6/lib/asciidoctor/pdf/converter.rb:2386:in `traverse'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-pdf-2.3.6/lib/asciidoctor/pdf/converter.rb:682:in `convert_section'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-pdf-2.3.6/lib/asciidoctor/pdf/converter.rb:152:in `convert'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-2.0.18/lib/asciidoctor/abstract_block.rb:75:in `convert'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-2.0.18/lib/asciidoctor/abstract_block.rb:84:in `block in content'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-2.0.18/lib/asciidoctor/abstract_block.rb:84:in `map'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-2.0.18/lib/asciidoctor/abstract_block.rb:84:in `content'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-pdf-2.3.6/lib/asciidoctor/pdf/converter.rb:2386:in `traverse'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-pdf-2.3.6/lib/asciidoctor/pdf/converter.rb:682:in `convert_section'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-pdf-2.3.6/lib/asciidoctor/pdf/converter.rb:152:in `convert'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-2.0.18/lib/asciidoctor/abstract_block.rb:75:in `convert'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-2.0.18/lib/asciidoctor/abstract_block.rb:84:in `block in content'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-2.0.18/lib/asciidoctor/abstract_block.rb:84:in `map'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-2.0.18/lib/asciidoctor/abstract_block.rb:84:in `content'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-pdf-2.3.6/lib/asciidoctor/pdf/converter.rb:2386:in `traverse'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-pdf-2.3.6/lib/asciidoctor/pdf/converter.rb:682:in `convert_section'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-pdf-2.3.6/lib/asciidoctor/pdf/converter.rb:152:in `convert'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-2.0.18/lib/asciidoctor/abstract_block.rb:75:in `convert'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-2.0.18/lib/asciidoctor/abstract_block.rb:84:in `block in content'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-2.0.18/lib/asciidoctor/abstract_block.rb:84:in `map'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-2.0.18/lib/asciidoctor/abstract_block.rb:84:in `content'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-2.0.18/lib/asciidoctor/document.rb:1012:in `content'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-pdf-2.3.6/lib/asciidoctor/pdf/converter.rb:2386:in `traverse'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-pdf-2.3.6/lib/asciidoctor/pdf/converter.rb:292:in `block in convert_document'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-pdf-2.3.6/lib/asciidoctor/pdf/converter.rb:616:in `indent_section'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-pdf-2.3.6/lib/asciidoctor/pdf/converter.rb:200:in `convert_document'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-pdf-2.3.6/lib/asciidoctor/pdf/converter.rb:152:in `convert'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-2.0.18/lib/asciidoctor/document.rb:956:in `convert'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-2.0.18/lib/asciidoctor/convert.rb:118:in `convert'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-2.0.18/lib/asciidoctor/convert.rb:190:in `block in convert_file'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-2.0.18/lib/asciidoctor/convert.rb:190:in `open'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-2.0.18/lib/asciidoctor/convert.rb:190:in `convert_file'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-2.0.18/lib/asciidoctor/cli/invoker.rb:129:in `block in invoke!'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-2.0.18/lib/asciidoctor/cli/invoker.rb:112:in `each'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-2.0.18/lib/asciidoctor/cli/invoker.rb:112:in `invoke!'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/vendor/bundle/ruby/2.6.0/gems/asciidoctor-pdf-2.3.6/bin/asciidoctor-pdf:46:in `<top (required)>'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/bin/asciidoctor-pdf:27:in `load'
    from /home/runner/work/riscv-total-embedded/riscv-total-embedded/bin/asciidoctor-pdf:27:in `<main>'
make: *** [Makefile:10: riscv-total-embedded.pdf] Error 1
Error: Process completed with exit code 2.

looks like classic "managed language" typo in code

jnk0le commented 1 year ago

On further testing it seems related to wavedrom images

[wavedrom, , svg]
....
....
mojavelinux commented 1 year ago

This pertains to Asciidoctor PDF. It was likely caused by this change: https://github.com/asciidoctor/asciidoctor-pdf/commit/2856671fc8ddb797bc7ad922b56a6eb7dacf4fad

However, what this points to is that the version of Ruby you are using is too old. The minimum supported version of Ruby is 2.7 (as indicated by the CI workflow: https://github.com/asciidoctor/asciidoctor-pdf/blob/v2.3.x/.github/workflows/ci.yml#L47 If you use at least Ruby 2.7, then your workflow will work. If you can't upgrade your version of Ruby, then you will need to pin the version of Asciidoctor PDF to 2.3.5 or earlier.

I'll wait for you to confirm this information before closing the issue.

jnk0le commented 1 year ago

ruby 2.7 worked.

How about a warning on "too old ruby version, some features may fail"?

mojavelinux commented 1 year ago

That's not a policy we use in Asciidoctor. And it's unreasonable to look for what is not there. Instead, you should refer to the README, CHANGELOG, or documentation.

Btw, support for Ruby < 2.7 was dropped from Asciidoctor PDF a year ago in #2038 and mentioned in the CHANGELOG. Ruby < 2.7 went EOL in in Apr 2022 (see https://www.ruby-lang.org/en/downloads/branches/). Ruby 2.7 is about to go EOL. The current version of Ruby is 3.2.

jnk0le commented 1 year ago

well, the changelog and documentation is easy to miss, especially in case of stackoverflow driven development. (of course I did miss it)

The warning would would immediately tell the user to update ruby, when approching weird errors. Therefore you won't get spammed by "old ruby errors" issues, and if done so, it will be less wasted time due to screaming logs.

Ruby 2.7 is about to go EOL. The current version of Ruby is 3.2.

Ruby 3.2 will eventually go EOL as well, and we will be in the same situation again.

mojavelinux commented 1 year ago

well, the changelog and documentation is easy to miss, especially in case of stackoverflow driven development. (of course I did miss it)

I'm sorry if you didn't take the time to look. I spend a ridiculous amount of time making sure the community has the information it needs to use this software. I update the documentation constantly to ensure it has the most accurate and up to date information possible.

Therefore you won't get spammed by "old ruby errors" issues, and if done so, it will be less wasted time due to screaming logs.

No, the users can respect the policies of this project, which is to read and understand prerequisites before reporting issues. If they do not, then it will result in these kinds of conversations.

Ruby 3.2 will eventually go EOL as well, and we will be in the same situation again.

If you want your set up to never change, I've already said you have the option of pinning the version of Asciidoctor PDF (as you do the Ruby version). You script is intentionally installing the latest version, which is going to change and will bring with it new requirements. Nothing is going to change that fact.

jnk0le commented 1 year ago

I'm sorry if you didn't take the time to look

BTW, originally (incorrectly) posted issue in asciidoctor/asciidoctor ("About" says it generates to "other formats") where the readme doesn't say anything about pure ruby version required (only the cruby, jruby, and truffleruby) and the newest pure ruby version referenced in Releases page is 2.3.

You script is intentionally installing the latest version, which is going to change and will bring with it new requirements. Nothing is going to change that fact.

As are typical stackoverflow samples.

Anyway, if the first log said that the "ruby version is too old/not officially supported, issues will not be accepted", that would be 30 seconds to fix for me, and 0 seconds of your time wasted.

mojavelinux commented 1 year ago

if the first log said that the "ruby version is too old/not officially supported, issues will not be accepted"

The issue template now says this.