asciidoctor-pdf: Image lookup does not work if both `pdf-themesdir` and `pdf-theme` are set to distinct `uri:classloader:` paths
Can there possibly be some regression @mojavelinux? It seems despite me specifying a pdf-themesdir
(as a ~uri:classpath
~ uri:classloader
), the background-image
is being prefixed with a local path. This code triggers
Dec 29, 2022 7:50:30 PM uri:classloader:/gems/asciidoctor-pdf-2.3.4/lib/asciidoctor/pdf/converter.rb resolve_background_image WARNING: title page background image not found or readable: C:/Users/SEBAST~1/AppData/Local/Temp/ort-PdfTemplateReporter-asciidoc8842694912548045678/uri:classloader:/images/ort.png
Hmm, or does pdf-themesdir
(in contrast to pdf-fontsdir
) not support ~uri:classpath
~ uri:classloader
? At least it’s not explicitly mentioned in the docs.
_Originally posted by @sschuberth in https://github.com/asciidoctor/asciidoctor-pdf/issues/1829#issuecomment-1367529272_
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 39 (22 by maintainers)
Commits related to this issue
- refactor(reporter): Simplify setting the PDF theme and image Asciidoctor(J)-PDF 2.3.6 [1] includes a work-around for a bug in JRuby 9.4 that causes `uri:classloader:` paths to be recognized as absolu... — committed to oss-review-toolkit/ort by sschuberth a year ago
- refactor(reporter): Simplify setting the PDF theme and image Asciidoctor(J)-PDF 2.3.6 [1] includes a work-around for a bug in JRuby 9.4 that causes `uri:classloader:` paths to be recognized as absolu... — committed to oss-review-toolkit/ort by sschuberth a year ago
- refactor(reporter): Simplify setting the PDF theme and image Asciidoctor(J)-PDF 2.3.6 [1] includes a work-around for a bug in JRuby 9.4 that causes `uri:classloader:` paths to be recognized as absolu... — committed to oss-review-toolkit/ort by sschuberth a year ago
@sschuberth The workaround is included in the 2.3.6 release. I’ll probably keep it in the 2.3.x release line, but remove it from main once we can confirm that JRuby handles the logic.
@mojavelinux I have not stepped through this yet but that is baffling to me too. There are specs to test absolute_path? but because I forgot this should have added our value-added logic for URIs it just calls the most obvious methods (and the normal ruby specs for this pass). When I figure this out we will definitely add tests for this and probably audit what else is calling the methods which made this return true.
I don’t have time to track this down right now. But I am trying to get a patch into Asciidoctor PDF to work around it since this has the potential for causing a lot of problems for people upgrading.
I found the exact change. Consider the following Ruby script:
Here are the results with different versions of JRuby:
What happened is that JRuby 9.4.2.0 implemented
File.absolute_path?
for the first time, but its return value does not matchPathname#absolute?
. That breaks the following assumption in Asciidoctor PDF: https://github.com/asciidoctor/asciidoctor-pdf/blob/main/lib/asciidoctor/pdf/ext/core/file.rbThat means we can’t rely on it. I can put in a workaround in the meantime, but this really strikes me as a bug in JRuby. I don’t see why these two return values should be different.