Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined method 'role=' for #<Asciidoctor::Block:0x0000563c79016010> #2363

Closed
Adspectus opened this issue Oct 26, 2022 · 9 comments
Closed
Assignees
Milestone

Comments

@Adspectus
Copy link

I followed the instructions and installed asciidoctor-pdf. The output of asciidoctor-pdf -v is:

Asciidoctor PDF 2.3.3 using Asciidoctor 2.0.10 [https://asciidoctor.org]
Runtime Environment (ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux-gnu]) (lc:UTF-8 fs:UTF-8 in:UTF-8 ex:UTF-8)

However, when I try to convert a very basic document, I get the errormentioned in the title. Added --trace gives me:

Traceback (most recent call last):
	22: from /usr/local/bin/asciidoctor-pdf:23:in `<main>'
	21: from /usr/local/bin/asciidoctor-pdf:23:in `load'
	20: from /var/lib/gems/2.7.0/gems/asciidoctor-pdf-2.3.3/bin/asciidoctor-pdf:46:in `<top (required)>'
	19: from /usr/lib/ruby/vendor_ruby/asciidoctor/cli/invoker.rb:111:in `invoke!'
	18: from /usr/lib/ruby/vendor_ruby/asciidoctor/cli/invoker.rb:111:in `each'
	17: from /usr/lib/ruby/vendor_ruby/asciidoctor/cli/invoker.rb:128:in `block in invoke!'
	16: from /usr/lib/ruby/vendor_ruby/asciidoctor/convert.rb:183:in `convert_file'
	15: from /usr/lib/ruby/vendor_ruby/asciidoctor/convert.rb:183:in `open'
	14: from /usr/lib/ruby/vendor_ruby/asciidoctor/convert.rb:183:in `block in convert_file'
	13: from /usr/lib/ruby/vendor_ruby/asciidoctor/convert.rb:118:in `convert'
	12: from /usr/lib/ruby/vendor_ruby/asciidoctor/document.rb:951:in `convert'
	11: from /var/lib/gems/2.7.0/gems/asciidoctor-pdf-2.3.3/lib/asciidoctor/pdf/converter.rb:152:in `convert'
	10: from /var/lib/gems/2.7.0/gems/asciidoctor-pdf-2.3.3/lib/asciidoctor/pdf/converter.rb:200:in `convert_document'
	 9: from /var/lib/gems/2.7.0/gems/asciidoctor-pdf-2.3.3/lib/asciidoctor/pdf/converter.rb:612:in `indent_section'
	 8: from /var/lib/gems/2.7.0/gems/asciidoctor-pdf-2.3.3/lib/asciidoctor/pdf/converter.rb:292:in `block in convert_document'
	 7: from /var/lib/gems/2.7.0/gems/asciidoctor-pdf-2.3.3/lib/asciidoctor/pdf/converter.rb:2378:in `traverse'
	 6: from /usr/lib/ruby/vendor_ruby/asciidoctor/document.rb:1020:in `content'
	 5: from /usr/lib/ruby/vendor_ruby/asciidoctor/abstract_block.rb:84:in `content'
	 4: from /usr/lib/ruby/vendor_ruby/asciidoctor/abstract_block.rb:84:in `map'
	 3: from /usr/lib/ruby/vendor_ruby/asciidoctor/abstract_block.rb:84:in `block in content'
	 2: from /usr/lib/ruby/vendor_ruby/asciidoctor/abstract_block.rb:75:in `convert'
	 1: from /var/lib/gems/2.7.0/gems/asciidoctor-pdf-2.3.3/lib/asciidoctor/pdf/converter.rb:152:in `convert'
/var/lib/gems/2.7.0/gems/asciidoctor-pdf-2.3.3/lib/asciidoctor/pdf/converter.rb:768:in `convert_preamble': undefined method `role=' for #<Asciidoctor::Block:0x0000559bc5862a48> (NoMethodError)
Did you mean?  role
               role?
               roles

I do not use role anywhere in my document.

@mojavelinux
Copy link
Member

Can you please provide a sample document?

The error message isn't saying that you have a role. The error message is saying that when it goes looking for a role, the object it's looking at is undefined.

@Adspectus
Copy link
Author

Hm, I don't really understand, but here is a test document:

= The Dangers of Wolpertingers

Don't worry about gumberoos or splintercats.

Something far more fearsome plagues the days, nights, and inbetweens.

Wolpertingers.

== Origins

Wolpertingers are https://en.wikipedia.org/wiki/Wolpertinger

When you remove the section heading == Origins or comment it out, no error is thrown.

@mojavelinux
Copy link
Member

It looks like it's some sort of parsing error when the document has a preamble, perhaps one with multiple paragraphs. I'll have a look.

@mojavelinux mojavelinux self-assigned this Oct 26, 2022
@mojavelinux mojavelinux added this to the v2.3.x milestone Oct 26, 2022
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue Oct 27, 2022
…o ensure compatbility with Asciidoctor 2.0.10
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue Oct 27, 2022
…o ensure compatbility with Asciidoctor 2.0.10
@mojavelinux
Copy link
Member

The issue is here:

Asciidoctor 2.0.10

That's a very old version of Asciidoctor which is missing the method in question. However, I have determined that it's reasonable for me to make the adjustments to support that version of Asciidoctor as the minimum allowable version. I have a submitted a PR to do that. We'll also run CI against the minimum required version of Asciidoctor and document it in the README.

In the meantime, you can fix the issue you're having by upgrading Asciidoctor to at least 2.0.11 (ideally 2.0.18).

@Adspectus
Copy link
Author

That's a very old version of Asciidoctor which is missing the method in question.

Well, I installed it according to the recommendations and supported systems (https://docs.asciidoctor.org/asciidoctor/latest/install/) on a Ubuntu 20.04 computer, hence I would expect that these error is not supposed to appear. Is there an apt repo which I can use to have a more up-to-date version of asciidoctor and still use the package manager?

@mojavelinux
Copy link
Member

mojavelinux commented Oct 27, 2022

Unfortunately, we have no control over the versions of gems that Linux distributions package. We advise them to always ship the latest patch release, but they don't always follow that recommendation (sometimes due to availability and sometimes due to choice). And those packages sometimes use versions which are not specified in our gemspec (package metadata). The best we can do is try to maintain compatibility for what active Linux distributions will package. And I will tell you I work my tail off to do exactly that.

If you want the latest gem versions, we strongly suggest using gem packaging / bundler as advised on this page: https://docs.asciidoctor.org/asciidoctor/latest/install/ruby-packaging/

@mojavelinux
Copy link
Member

I would expect that these error is not supposed to appear.

...and I already said I would address that situation.

@Adspectus
Copy link
Author

Yes, and I appreciate this. I will check the provided link and try to update.

Thanks for taking care of this so fast!

@mojavelinux
Copy link
Member

Interesting to note that the current Ubuntu LTS packages asciidoctor 2.0.16 (https://packages.ubuntu.com/jammy/asciidoctor). Still not 2.0.18, but certainly more recent than what is packaged for 20.04.

mojavelinux added a commit that referenced this issue Oct 27, 2022
…nsure compatbility with Asciidoctor 2.0.10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants