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 `position' for #<Nokogiri::XML::Element:0x0000000002465008> (NoMethodError) #24

Closed
deivid-rodriguez opened this issue Feb 7, 2019 · 11 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@deivid-rodriguez
Copy link
Contributor

In order to generate bundler's man pages, we currently use the ronn gem. However, this gem and its dependencies have not been updated for years, and just now I found out that they started segfaulting in some situations.

I tried replacing ronn with ronn-ng. It did generate some man pages (didn't check correctness, but it didn't crash), but it ended up crashing with the following error

/home/travis/.rvm/rubies/ruby-2.6.1/bin/ruby -S ronn --roff --pipe man/gemfile.5.ronn > man/gemfile.5
warn: unrecognized inline tag: ["p"]
warn: unrecognized inline tag: ["p"]
warn: unrecognized inline tag: ["p"]
Traceback (most recent call last):
	23: from /home/travis/.rvm/gems/ruby-2.6.1/bin/ronn:23:in `<main>'
	22: from /home/travis/.rvm/gems/ruby-2.6.1/bin/ronn:23:in `load'
	21: from /home/travis/.rvm/gems/ruby-2.6.1/gems/ronn-ng-0.8.0.SNAPSHOT/bin/ronn:184:in `<top (required)>'
	20: from /home/travis/.rvm/gems/ruby-2.6.1/gems/ronn-ng-0.8.0.SNAPSHOT/bin/ronn:184:in `each'
	19: from /home/travis/.rvm/gems/ruby-2.6.1/gems/ronn-ng-0.8.0.SNAPSHOT/bin/ronn:199:in `block in <top (required)>'
	18: from /home/travis/.rvm/gems/ruby-2.6.1/gems/ronn-ng-0.8.0.SNAPSHOT/bin/ronn:199:in `each'
	17: from /home/travis/.rvm/gems/ruby-2.6.1/gems/ronn-ng-0.8.0.SNAPSHOT/bin/ronn:220:in `block (2 levels) in <top (required)>'
	16: from /home/travis/.rvm/gems/ruby-2.6.1/gems/ronn-ng-0.8.0.SNAPSHOT/lib/ronn/document.rb:238:in `convert'
	15: from /home/travis/.rvm/gems/ruby-2.6.1/gems/ronn-ng-0.8.0.SNAPSHOT/lib/ronn/document.rb:243:in `to_roff'
	14: from /home/travis/.rvm/gems/ruby-2.6.1/gems/ronn-ng-0.8.0.SNAPSHOT/lib/ronn/document.rb:243:in `new'
	13: from /home/travis/.rvm/gems/ruby-2.6.1/gems/ronn-ng-0.8.0.SNAPSHOT/lib/ronn/roff.rb:18:in `initialize'
	12: from /home/travis/.rvm/gems/ruby-2.6.1/gems/ronn-ng-0.8.0.SNAPSHOT/lib/ronn/roff.rb:91:in `block_filter'
	11: from /home/travis/.rvm/gems/ruby-2.6.1/gems/ronn-ng-0.8.0.SNAPSHOT/lib/ronn/roff.rb:88:in `block_filter'
	10: from /home/travis/.rvm/gems/ruby-2.6.1/gems/nokogiri-1.10.1/lib/nokogiri/xml/node_set.rb:237:in `each'
	 9: from /home/travis/.rvm/gems/ruby-2.6.1/gems/nokogiri-1.10.1/lib/nokogiri/xml/node_set.rb:237:in `upto'
	 8: from /home/travis/.rvm/gems/ruby-2.6.1/gems/nokogiri-1.10.1/lib/nokogiri/xml/node_set.rb:238:in `block in each'
	 7: from /home/travis/.rvm/gems/ruby-2.6.1/gems/ronn-ng-0.8.0.SNAPSHOT/lib/ronn/roff.rb:88:in `block in block_filter'
	 6: from /home/travis/.rvm/gems/ruby-2.6.1/gems/ronn-ng-0.8.0.SNAPSHOT/lib/ronn/roff.rb:160:in `block_filter'
	 5: from /home/travis/.rvm/gems/ruby-2.6.1/gems/ronn-ng-0.8.0.SNAPSHOT/lib/ronn/roff.rb:88:in `block_filter'
	 4: from /home/travis/.rvm/gems/ruby-2.6.1/gems/nokogiri-1.10.1/lib/nokogiri/xml/node_set.rb:237:in `each'
	 3: from /home/travis/.rvm/gems/ruby-2.6.1/gems/nokogiri-1.10.1/lib/nokogiri/xml/node_set.rb:237:in `upto'
	 2: from /home/travis/.rvm/gems/ruby-2.6.1/gems/nokogiri-1.10.1/lib/nokogiri/xml/node_set.rb:238:in `block in each'
	 1: from /home/travis/.rvm/gems/ruby-2.6.1/gems/ronn-ng-0.8.0.SNAPSHOT/lib/ronn/roff.rb:88:in `block in block_filter'
/home/travis/.rvm/gems/ruby-2.6.1/gems/ronn-ng-0.8.0.SNAPSHOT/lib/ronn/roff.rb:165:in `block_filter': undefined method `position' for #<Nokogiri::XML::Element:0x0000000002465008> (NoMethodError)

In order to reproduce, you can clone bundler, replace the ronn development dependency with ronn-ng, and then run bin/rake spec:deps followed by bin/rake man:build.

Thanks!

@ssgelm
Copy link

ssgelm commented Feb 8, 2019

I ran into this also with git-lfs and it appears to be caused by having a numbered list. Any man pages without one work fine. Here's a really simple one that worked before but now fails:

test
====

## SYNOPSIS

 1. Test

@deivid-rodriguez
Copy link
Contributor Author

Thanks @ssgelm for digging into it! This gem looks very promising if this is fixed! 🎉

@boutil boutil mentioned this issue Feb 12, 2019
@apjanke apjanke self-assigned this Feb 17, 2019
@apjanke apjanke added the bug Something isn't working label Feb 17, 2019
@apjanke apjanke added this to the 0.8.1 milestone Feb 17, 2019
@apjanke
Copy link
Owner

apjanke commented Feb 17, 2019

Thanks for the report! Prioritizing this bug since it's causing problems for Debian.

Looks like this could be a leftover bug from the hpricot-to-Nokogiri migration.

@ssgelm
Copy link

ssgelm commented Feb 17, 2019

@apjanke Thanks for looking into it! Please let me know if I can help in any way.

@apjanke
Copy link
Owner

apjanke commented Feb 17, 2019

This was indeed an hpricot-to-Nokogiri migration bug.

It looks like one of those fabled one-line fixes: e91949f#diff-8c2a2b56f00218c211ba4fc3ed93077c

This fix won't fix all ordered list rendering: in particular, I don't know whether nested ordered lists are working well. But it fixes this regression and gets Ronn-NG back to what the original Ronn supported. And should get your man pages building.

I added an ordered list test to Ronn-NG's test suite, and the results look good to me, based on manual inspection and viewing under man on macOS.

Fixes the git-lfs man build failure for me, though I haven't inspected the resulting pages for correctness.

Before:

[~/local/repos/git-lfs]
$ make man                                                                                                     testing-ronn-ng
ronn  -r --pipe < docs/man/git-lfs-checkout.1.ronn > man/git-lfs-checkout.1
ronn  -r --pipe < docs/man/git-lfs-clean.1.ronn > man/git-lfs-clean.1
[...]
ronn  -r --pipe < docs/man/git-lfs.1.ronn > man/git-lfs.1
Traceback (most recent call last):
	23: from /usr/local/Cellar/ronn-ng/0.8.0/libexec/bin/ronn:23:in `<main>'
	22: from /usr/local/Cellar/ronn-ng/0.8.0/libexec/bin/ronn:23:in `load'
[...]
	 2: from /usr/local/lib/ruby/gems/2.6.0/gems/nokogiri-1.10.1/lib/nokogiri/xml/node_set.rb:238:in `block in each'
	 1: from /usr/local/Cellar/ronn-ng/0.8.0/libexec/gems/ronn-ng-0.8.0/lib/ronn/roff.rb:88:in `block in block_filter'
/usr/local/Cellar/ronn-ng/0.8.0/libexec/gems/ronn-ng-0.8.0/lib/ronn/roff.rb:165:in `block_filter': undefined method `position' for #<Nokogiri::XML::Element:0x00007fdf5990f048> (NoMethodError)
make: *** [man/git-lfs.1] Error 1

After:

[~/local/repos/git-lfs]
$ make man                                                                                    testing-ronn-ng
ronn  -5 --pipe < docs/man/git-lfs-checkout.1.ronn > man/git-lfs-checkout.1.html
ronn  -5 --pipe < docs/man/git-lfs-clean.1.ronn > man/git-lfs-clean.1.html
[...]
ronn  -5 --pipe < docs/man/git-lfs.1.ronn > man/git-lfs.1.html
[~/local/repos/git-lfs]
$

This fix justifies a patch release since the problem is affecting end users and especially because it's a regression from original Ronn.

I've pushed out an 0.8.1.beta.1 release with this fix included. Can you test it out? Install with brew install ronn-ng --devel on macOS or gem install ronn-ng --pre on other platforms.

@apjanke
Copy link
Owner

apjanke commented Feb 17, 2019

@deivid-rodriguez I think I've got this fixed for you, but I'm not enough of a Ruby wizard to get the bundler man page build working with the ronn-ng gem. Could you test it against the ronn-ng 0.8.1.beta.1 gem and see if it's working for you under that?

@ssgelm
Copy link

ssgelm commented Feb 17, 2019

Seems to work for me. I diffed the old and new man pages and there seem to be some slight differences but none that cause obvious visual differences so I think it's fine.

@apjanke
Copy link
Owner

apjanke commented Feb 17, 2019

Great.

Yeah, the ROFF output isn't going to be byte-for-byte identical between Ronn and Ronn-NG – in particular, I've removed what I considered to be excess non-significant whitespace that hindered readability for experienced ROFF users (who are the only folks that should be reading raw ROFF files ;) ) – but it should render the same (in most cases) or “better” (in the case of nested lists or some other indented constructs).

@apjanke
Copy link
Owner

apjanke commented Feb 17, 2019

BTW, sorry for taking so long to respond to this bug report. I had food poisoning earlier this week. :(

@deivid-rodriguez
Copy link
Contributor Author

Tried it and it worked just fine! As @ssgelm pointed out, I also diffed the generated man pages and they show minor changes that don't seem to make any visual difference.

So this seems fixed, thanks!!

@apjanke
Copy link
Owner

apjanke commented Mar 5, 2019

This fix went out in version 0.8.1.

@apjanke apjanke added this to ronn-ng Jan 4, 2024
@apjanke apjanke moved this to Closed in ronn-ng Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

No branches or pull requests

3 participants