pygments.rb: Broken pipe error in Mentos
Hello!
I have faced an error while trying to use pygments.rb with asciidoctor:
Broken pipe - Failed to read response from Python process on a mentos get_all_lexers call: Python (MentosError)
I am using the latest version of Pygments.rb (2.3.0), Asciidoctor (2.0.18), Python (3.11.0) and Ruby (3.1.0).
Steps to reproduce:
- Create a test asciidoctor document with the following contents:
= Test syntax highlight error
:source-highlighter: pygments
:pygments-style: default
[source,java]
----
class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
----
- Run command in command line:
asciidoctor --trace <path to the file from paragrapth 1> - Check the error:
C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/pygments.rb-2.3.0/lib/pygments/popen.rb:292:in `rescue in mentos': Broken pipe - Failed to read response from Python process on a mentos get_all_lexers call: Python (MentosError)
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/pygments.rb-2.3.0/lib/pygments/popen.rb:266:in `mentos'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/pygments.rb-2.3.0/lib/pygments/popen.rb:118:in `lexers!'
from C:/Program Files/Ruby31-x64/lib/ruby/3.1.0/forwardable.rb:238:in `lexers!'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/pygments.rb-2.3.0/lib/pygments/lexer.rb:134:in `initialize'
from C:/Program Files/Ruby31-x64/lib/ruby/3.1.0/singleton.rb:127:in `new'
from C:/Program Files/Ruby31-x64/lib/ruby/3.1.0/singleton.rb:127:in `block in instance'
from C:/Program Files/Ruby31-x64/lib/ruby/3.1.0/singleton.rb:125:in `synchronize'
from C:/Program Files/Ruby31-x64/lib/ruby/3.1.0/singleton.rb:125:in `instance'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/pygments.rb-2.3.0/lib/pygments/lexer.rb:61:in `find_by_alias'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/syntax_highlighter/pygments.rb:16:in `highlight'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/substitutors.rb:958:in `highlight_source'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/substitutors.rb:104:in `block in apply_subs'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/substitutors.rb:91:in `each'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/substitutors.rb:91:in `apply_subs'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/block.rb:117:in `content'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/syntax_highlighter.rb:243:in `format'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/syntax_highlighter/pygments.rb:57:in `format'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/converter/html5.rb:678:in `convert_listing'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/converter/html5.rb:56:in `convert'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/abstract_block.rb:75:in `convert'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/abstract_block.rb:84:in `block in content'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/abstract_block.rb:84:in `map'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/abstract_block.rb:84:in `content'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/document.rb:1012:in `content'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/converter/html5.rb:227:in `convert_document'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/converter/html5.rb:85:in `convert'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/document.rb:956:in `convert'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/convert.rb:118:in `convert'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/convert.rb:190:in `block in convert_file'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/convert.rb:190:in `open'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/convert.rb:190:in `convert_file'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/cli/invoker.rb:129:in `block in invoke!'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/cli/invoker.rb:112:in `each'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/cli/invoker.rb:112:in `invoke!'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/bin/asciidoctor:15:in `<top (required)>'
from C:/Program Files/Ruby31-x64/bin/asciidoctor:32:in `load'
from C:/Program Files/Ruby31-x64/bin/asciidoctor:32:in `<main>'
C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/pygments.rb-2.3.0/lib/pygments/popen.rb:274:in `block in mentos': Broken pipe - Failed to read response from Python process on a mentos get_all_lexers call (Errno::EPIPE)
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/pygments.rb-2.3.0/lib/pygments/popen.rb:241:in `with_watchdog'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/pygments.rb-2.3.0/lib/pygments/popen.rb:268:in `mentos'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/pygments.rb-2.3.0/lib/pygments/popen.rb:118:in `lexers!'
from C:/Program Files/Ruby31-x64/lib/ruby/3.1.0/forwardable.rb:238:in `lexers!'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/pygments.rb-2.3.0/lib/pygments/lexer.rb:134:in `initialize'
from C:/Program Files/Ruby31-x64/lib/ruby/3.1.0/singleton.rb:127:in `new'
from C:/Program Files/Ruby31-x64/lib/ruby/3.1.0/singleton.rb:127:in `block in instance'
from C:/Program Files/Ruby31-x64/lib/ruby/3.1.0/singleton.rb:125:in `synchronize'
from C:/Program Files/Ruby31-x64/lib/ruby/3.1.0/singleton.rb:125:in `instance'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/pygments.rb-2.3.0/lib/pygments/lexer.rb:61:in `find_by_alias'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/syntax_highlighter/pygments.rb:16:in `highlight'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/substitutors.rb:958:in `highlight_source'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/substitutors.rb:104:in `block in apply_subs'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/substitutors.rb:91:in `each'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/substitutors.rb:91:in `apply_subs'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/block.rb:117:in `content'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/syntax_highlighter.rb:243:in `format'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/syntax_highlighter/pygments.rb:57:in `format'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/converter/html5.rb:678:in `convert_listing'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/converter/html5.rb:56:in `convert'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/abstract_block.rb:75:in `convert'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/abstract_block.rb:84:in `block in content'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/abstract_block.rb:84:in `map'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/abstract_block.rb:84:in `content'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/document.rb:1012:in `content'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/converter/html5.rb:227:in `convert_document'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/converter/html5.rb:85:in `convert'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/document.rb:956:in `convert'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/convert.rb:118:in `convert'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/convert.rb:190:in `block in convert_file'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/convert.rb:190:in `open'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/convert.rb:190:in `convert_file'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/cli/invoker.rb:129:in `block in invoke!'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/cli/invoker.rb:112:in `each'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/cli/invoker.rb:112:in `invoke!'
from C:/Program Files/Ruby31-x64/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/bin/asciidoctor:15:in `<top (required)>'
from C:/Program Files/Ruby31-x64/bin/asciidoctor:32:in `load'
from C:/Program Files/Ruby31-x64/bin/asciidoctor:32:in `<main>'
Could you please help me identify the cause of the problem and fix it?
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 19
Commits related to this issue
- resolves #242 fix bogus search for Python executable — committed to slonopotamus/pygments.rb by slonopotamus 2 years ago
- resolves #242 fix bogus search for Python executable — committed to slonopotamus/pygments.rb by slonopotamus 2 years ago
- resolves #242 fix bogus search for Python executable — committed to slonopotamus/pygments.rb by slonopotamus 2 years ago
I have tested v.2.3.1 - everything works well! The problem has been fixed. I have tested
pygments.rbwith bothasciidoctorandasciidoctor-pdf. The output document has been generated without any issues and the code highlight is correct: test.pdfThank you for help and advice! I will give this username a try 😃
Thanks a lot! That was indeed the issue.
I made a PR to fix the issue.
@this-username-has-been-taken @antoyo guys, please give v2.3.1 a try.
@this-username-has-been-taken sorry to hear that your username was taken.