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

JSON5 lexer may fail to load in Ruby < 3.0 #2083

Closed
t-kinoshita opened this issue Nov 11, 2024 · 1 comment · Fixed by #2084
Closed

JSON5 lexer may fail to load in Ruby < 3.0 #2083

t-kinoshita opened this issue Nov 11, 2024 · 1 comment · Fixed by #2084
Assignees
Labels
bugfix-request A request for a bugfix to be developed. pr-open A PR addressing this issue is open.

Comments

@t-kinoshita
Copy link

Please note: This is for non-lexer bugs.

Describe the bug
failed in loading Rouge::Lexers::JSON5

TypeError: superclass must be a Class (Module given)
 /usr/local/bundle/gems/rouge-4.5.0/lib/rouge/lexers/json5.rb:8:in `<module:Lexers>'
 /usr/local/bundle/gems/rouge-4.5.0/lib/rouge/lexers/json5.rb:5:in `<module:Rouge>'
/usr/local/bundle/gems/rouge-4.5.0/lib/rouge/lexers/json5.rb:4:in `<main>'
/usr/local/bundle/gems/rouge-4.5.0/lib/rouge/lexer.rb:532:in `load'
/usr/local/bundle/gems/rouge-4.5.0/lib/rouge/lexer.rb:532:in `load_lexer'
/usr/local/bundle/gems/rouge-4.5.0/lib/rouge.rb:52:in `block in load_lexers'
/usr/local/bundle/gems/rouge-4.5.0/lib/rouge.rb:51:in `each'
/usr/local/bundle/gems/rouge-4.5.0/lib/rouge.rb:51:in `load_lexers'
/usr/local/bundle/gems/rouge-4.5.0/lib/rouge.rb:67:in `<main>'

It seems ::JSON is loaded instead of Rouge::Lexers::JSON.

Expected behavior
Successfully loaded without error

System (please complete the following information):

  • OS: Ubuntu 22.04 LTS
  • Ruby version 2.7.8
  • Rouge version: 4.5

Additional context
Pathname.glob (seen in Rouge.load_lexers) returns unordered list in Ruby < 3.0, so Rouge::Lexers::JSON may not loaded before Rouge::Lexers::JSON5 in such environments.

@t-kinoshita t-kinoshita added the bugfix-request A request for a bugfix to be developed. label Nov 11, 2024
@t-kinoshita t-kinoshita changed the title JSON5 parsers may break in Ruby <= 2.7 JSON5 lexer may fail to load in Ruby < 3.0 Nov 11, 2024
@tancnle tancnle self-assigned this Nov 11, 2024
@tancnle tancnle added the pr-open A PR addressing this issue is open. label Nov 11, 2024
@tancnle
Copy link
Collaborator

tancnle commented Nov 11, 2024

Thank you for reporting this bug @t-kinoshita 🙇🏼‍♂️ I have raised a PR to address it, will merge and push a patch in the next 24 hours.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix-request A request for a bugfix to be developed. pr-open A PR addressing this issue is open.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants