Skip to content

syntax_suggest CLI doesn't work when it is a standard gem #215

Description

@jeremyevans

The syntax_suggest CLI that ships in Ruby 3.3.0 and Ruby 3.2.3 fails:

$ /usr/local/bin/syntax_suggest33 -h
/usr/local/lib/ruby/gems/3.3/gems/syntax_suggest-2.0.0/exe/syntax_suggest:3:in `require_relative': cannot load such file -- /usr/local/lib/ruby/gems/3.3/gems/syntax_suggest-2.0.0/lib/syntax_suggest/api (LoadError)
        from /usr/local/lib/ruby/gems/3.3/gems/syntax_suggest-2.0.0/exe/syntax_suggest:3:in `<top (required)>'
        from /usr/local/bin/syntax_suggest33:25:in `load'
        from /usr/local/bin/syntax_suggest33:25:in `<main>'

$ /usr/local/bin/syntax_suggest32 -h
/usr/local/lib/ruby/gems/3.2/gems/syntax_suggest-1.1.0/exe/syntax_suggest:3:in `require_relative': cannot load such file -- /usr/local/lib/ruby/gems/3.2/gems/syntax_suggest-1.1.0/lib/syntax_suggest/api (LoadError)
        from /usr/local/lib/ruby/gems/3.2/gems/syntax_suggest-1.1.0/exe/syntax_suggest:3:in `<top (required)>'
        from /usr/local/bin/syntax_suggest32:25:in `load'
        from /usr/local/bin/syntax_suggest32:25:in `<main>'

To handle this case, I think syntax_suggest should rescue a LoadError failure in the require_relative call, and try to use a regular require. You can use require File.join(RbConfig::CONFIG['rubylibdir'], 'syntax_suggest', 'api') if you want to use an absolute path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions