Skip to content

Linux file system with square brackets in the directory/filename are failing to be indexed #3503

Description

@streetpaws

https://github.com/Shopify/ruby-lsp/blame/6acf78b6f5e94c8fd13be5ad7a4c82d083233853/lib/ruby_indexer/lib/ruby_indexer/uri.rb#L21

The unsafe_regexp includes square brackets and I'm finding this is causing the ruby-lsp indexing to fail when it comes across a file path like the following "/home/streetp/index[0]/example.rb".

When I modify the ruby_indexer code and change the unsafe_regexp, removing the square brackets, to be unsafe_regex = %r{[^\-_.!~*'()a-zA-Z\d;/?@&=+$,]}

Then it works. I haven't checked tested this for Windows/Mac - and I'm not aware of whether this may create issues but I know that I have these work filepaths on my system (and these generated filepaths that break ruby-lsp indexing are not things I can control and change).

For context, I am using VSCode on a Mac, and using the Microsoft Remote Extension to work on a Linux host and have the Ruby-Lsp extension installed remotely on the Linux host (so it's trying to index on that host and failing). This extension pulls in the ruby-lsp gem. In terms of ruby-lsp version it is as follows:

$ ruby-lsp --version
0.23.20

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp-wantedExtra attention is neededpinnedThis issue or pull request is pinned and won't be marked as stale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions