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

Error SystemStackError when ruby-lsp tries to index .crt file #2090

Closed
egor-khanko opened this issue May 27, 2024 · 4 comments
Closed

Error SystemStackError when ruby-lsp tries to index .crt file #2090

egor-khanko opened this issue May 27, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@egor-khanko
Copy link

Description

Reproduction steps

  1. Initialize new project with bundle init
  2. Add gem 'aws-sdk-core', '3.132.0' into Gemfile
  3. Install gems with bundle install --path=.bundle
  4. Create file .index.yml with:
included_patterns:
  - ".bundle/**/*"`
  1. Run ruby-lsp-doctor
  2. Observe stack level too deep (SystemStackError) error

Here are logs from this run:

Globbing for indexable files
indexing: /home/egor/Documents/work/aiir/tmp/.bundle/config
indexing: /home/egor/Documents/work/aiir/tmp/.bundle/ruby
indexing: /home/egor/Documents/work/aiir/tmp/.bundle/ruby/3.2.0
indexing: /home/egor/Documents/work/aiir/tmp/.bundle/ruby/3.2.0/bin
indexing: /home/egor/Documents/work/aiir/tmp/.bundle/ruby/3.2.0/bin/jmespath.rb
indexing: /home/egor/Documents/work/aiir/tmp/.bundle/ruby/3.2.0/build_info
indexing: /home/egor/Documents/work/aiir/tmp/.bundle/ruby/3.2.0/cache
indexing: /home/egor/Documents/work/aiir/tmp/.bundle/ruby/3.2.0/cache/aws-eventstream-1.3.0.gem
indexing: /home/egor/Documents/work/aiir/tmp/.bundle/ruby/3.2.0/cache/aws-partitions-1.934.0.gem
indexing: /home/egor/Documents/work/aiir/tmp/.bundle/ruby/3.2.0/cache/aws-sdk-core-3.132.0.gem
indexing: /home/egor/Documents/work/aiir/tmp/.bundle/ruby/3.2.0/cache/aws-sigv4-1.8.0.gem
indexing: /home/egor/Documents/work/aiir/tmp/.bundle/ruby/3.2.0/cache/jmespath-1.6.2.gem
indexing: /home/egor/Documents/work/aiir/tmp/.bundle/ruby/3.2.0/doc
indexing: /home/egor/Documents/work/aiir/tmp/.bundle/ruby/3.2.0/extensions
indexing: /home/egor/Documents/work/aiir/tmp/.bundle/ruby/3.2.0/gems
indexing: /home/egor/Documents/work/aiir/tmp/.bundle/ruby/3.2.0/gems/aws-eventstream-1.3.0
indexing: /home/egor/Documents/work/aiir/tmp/.bundle/ruby/3.2.0/gems/aws-eventstream-1.3.0/CHANGELOG.md
indexing: /home/egor/Documents/work/aiir/tmp/.bundle/ruby/3.2.0/gems/aws-eventstream-1.3.0/LICENSE.txt
indexing: /home/egor/Documents/work/aiir/tmp/.bundle/ruby/3.2.0/gems/aws-eventstream-1.3.0/VERSION
indexing: /home/egor/Documents/work/aiir/tmp/.bundle/ruby/3.2.0/gems/aws-eventstream-1.3.0/lib
indexing: /home/egor/Documents/work/aiir/tmp/.bundle/ruby/3.2.0/gems/aws-eventstream-1.3.0/lib/aws-eventstream
indexing: /home/egor/Documents/work/aiir/tmp/.bundle/ruby/3.2.0/gems/aws-eventstream-1.3.0/lib/aws-eventstream/decoder.rb
indexing: /home/egor/Documents/work/aiir/tmp/.bundle/ruby/3.2.0/gems/aws-eventstream-1.3.0/lib/aws-eventstream/encoder.rb
indexing: /home/egor/Documents/work/aiir/tmp/.bundle/ruby/3.2.0/gems/aws-eventstream-1.3.0/lib/aws-eventstream/errors.rb
indexing: /home/egor/Documents/work/aiir/tmp/.bundle/ruby/3.2.0/gems/aws-eventstream-1.3.0/lib/aws-eventstream/header_value.rb
indexing: /home/egor/Documents/work/aiir/tmp/.bundle/ruby/3.2.0/gems/aws-eventstream-1.3.0/lib/aws-eventstream/message.rb
indexing: /home/egor/Documents/work/aiir/tmp/.bundle/ruby/3.2.0/gems/aws-eventstream-1.3.0/lib/aws-eventstream/types.rb
indexing: /home/egor/Documents/work/aiir/tmp/.bundle/ruby/3.2.0/gems/aws-eventstream-1.3.0/lib/aws-eventstream.rb
indexing: /home/egor/Documents/work/aiir/tmp/.bundle/ruby/3.2.0/gems/aws-partitions-1.934.0
indexing: /home/egor/Documents/work/aiir/tmp/.bundle/ruby/3.2.0/gems/aws-partitions-1.934.0/CHANGELOG.md
/home/egor/.local/share/mise/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/prism-0.29.0/lib/prism/dispatcher.rb:216:in `each': stack level too deep (SystemStackError)
        from /home/egor/.local/share/mise/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/prism-0.29.0/lib/prism/dispatcher.rb:216:in `visit_call_node'
        from /home/egor/.local/share/mise/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/prism-0.29.0/lib/prism/node.rb:2513:in `accept'
        from /home/egor/.local/share/mise/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/prism-0.29.0/lib/prism/visitor.rb:31:in `block in visit_child_nodes'
        from /home/egor/.local/share/mise/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/prism-0.29.0/lib/prism/visitor.rb:31:in `each'
        from /home/egor/.local/share/mise/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/prism-0.29.0/lib/prism/visitor.rb:31:in `visit_child_nodes'
        from /home/egor/.local/share/mise/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/prism-0.29.0/lib/prism/dispatcher.rb:105:in `visit_arguments_node'
        from /home/egor/.local/share/mise/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/prism-0.29.0/lib/prism/node.rb:660:in `accept'
        from /home/egor/.local/share/mise/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/prism-0.29.0/lib/prism/visitor.rb:31:in `block in visit_child_nodes'
         ... 10385 levels...
        from /home/egor/.local/share/mise/installs/ruby/3.2.0/lib/ruby/3.2.0/bundler/friendly_errors.rb:117:in `with_friendly_errors'
        from /home/egor/.local/share/mise/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/bundler-2.4.1/libexec/bundle:33:in `<top (required)>'
        from /home/egor/.local/share/mise/installs/ruby/3.2.0/bin/bundle:25:in `load'
        from /home/egor/.local/share/mise/installs/ruby/3.2.0/bin/bundle:25:in `<main>'
@egor-khanko egor-khanko added the bug Something isn't working label May 27, 2024
@egor-khanko
Copy link
Author

Added this file to excluded_pattens in .index.yml
Have same issue with httpclient-2.8.3

indexing: /home/egor/Documents/work/aiir/coaching-zone-api/.bundle/ruby/3.2.0/gems/httpclient-2.8.3
indexing: /home/egor/Documents/work/aiir/coaching-zone-api/.bundle/ruby/3.2.0/gems/httpclient-2.8.3/README.md
indexing: /home/egor/Documents/work/aiir/coaching-zone-api/.bundle/ruby/3.2.0/gems/httpclient-2.8.3/bin
indexing: /home/egor/Documents/work/aiir/coaching-zone-api/.bundle/ruby/3.2.0/gems/httpclient-2.8.3/bin/httpclient
indexing: /home/egor/Documents/work/aiir/coaching-zone-api/.bundle/ruby/3.2.0/gems/httpclient-2.8.3/bin/jsonclient
indexing: /home/egor/Documents/work/aiir/coaching-zone-api/.bundle/ruby/3.2.0/gems/httpclient-2.8.3/lib
indexing: /home/egor/Documents/work/aiir/coaching-zone-api/.bundle/ruby/3.2.0/gems/httpclient-2.8.3/lib/hexdump.rb
indexing: /home/egor/Documents/work/aiir/coaching-zone-api/.bundle/ruby/3.2.0/gems/httpclient-2.8.3/lib/http-access2
indexing: /home/egor/Documents/work/aiir/coaching-zone-api/.bundle/ruby/3.2.0/gems/httpclient-2.8.3/lib/http-access2/cookie.rb
indexing: /home/egor/Documents/work/aiir/coaching-zone-api/.bundle/ruby/3.2.0/gems/httpclient-2.8.3/lib/http-access2/http.rb
indexing: /home/egor/Documents/work/aiir/coaching-zone-api/.bundle/ruby/3.2.0/gems/httpclient-2.8.3/lib/http-access2.rb
indexing: /home/egor/Documents/work/aiir/coaching-zone-api/.bundle/ruby/3.2.0/gems/httpclient-2.8.3/lib/httpclient
indexing: /home/egor/Documents/work/aiir/coaching-zone-api/.bundle/ruby/3.2.0/gems/httpclient-2.8.3/lib/httpclient/auth.rb
indexing: /home/egor/Documents/work/aiir/coaching-zone-api/.bundle/ruby/3.2.0/gems/httpclient-2.8.3/lib/httpclient/cacert.pem
/home/egor/.local/share/mise/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/prism-0.29.0/lib/prism/visitor.rb:31:in `visit_child_nodes': stack level too deep (SystemStackError)
        from /home/egor/.local/share/mise/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/prism-0.29.0/lib/prism/dispatcher.rb:401:in `visit_constant_read_node'
        from /home/egor/.local/share/mise/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/prism-0.29.0/lib/prism/node.rb:5545:in `accept'
        from /home/egor/.local/share/mise/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/prism-0.29.0/lib/prism/visitor.rb:31:in `block in visit_child_nodes'
        from /home/egor/.local/share/mise/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/prism-0.29.0/lib/prism/visitor.rb:31:in `each'
        from /home/egor/.local/share/mise/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/prism-0.29.0/lib/prism/visitor.rb:31:in `visit_child_nodes'
        from /home/egor/.local/share/mise/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/prism-0.29.0/lib/prism/dispatcher.rb:217:in `visit_call_node'
        from /home/egor/.local/share/mise/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/prism-0.29.0/lib/prism/node.rb:2513:in `accept'
        from /home/egor/.local/share/mise/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/prism-0.29.0/lib/prism/visitor.rb:31:in `block in visit_child_nodes'
         ... 10385 levels...
        from /home/egor/.local/share/mise/installs/ruby/3.2.0/lib/ruby/3.2.0/bundler/friendly_errors.rb:117:in `with_friendly_errors'
        from /home/egor/.local/share/mise/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/bundler-2.4.1/libexec/bundle:33:in `<top (required)>'
        from /home/egor/.local/share/mise/installs/ruby/3.2.0/bin/bundle:25:in `load'
        from /home/egor/.local/share/mise/installs/ruby/3.2.0/bin/bundle:25:in `<main>'

I suppose this issue happens because I'am indexing everything inside .bundle folder, but I thought the gem will index only ruby or ruby-like files (files on which it can provide useful information).

@vinistock
Copy link
Member

Thank you for the issue report. There are certain occasions where you may want to index files with different extensions. For example, we may want to index RBI/RBS files to enhance the index information with type information (currently doesn't work, but it might in the future).

I don't believe the index should enforce that all included files must have a Ruby extension. I think the fix here is to restrict your glob pattern to Ruby files.

included_patterns:
  - ".bundle/**/*.rb"

Also, please note that we're discussing the existence of this .index.yml file as it kind of breaks the approach taken by most language servers, which rely on editor configuration files (like .vscode/settings.json for VS Code) instead of using custom files. That is, this file may be going away some time soon.

@vinistock vinistock closed this as not planned Won't fix, can't repro, duplicate, stale May 27, 2024
@egor-khanko
Copy link
Author

@vinistock Thank you for quick response!
By ruby files I did not only meant all .rb files, but just all files that will be useful for completeion inside ruby files, so that also includes RBI/RBS.
I don't understand how files with cerificates, code of conduct, etc. will be helpful for completion.

But maybe you are right, it is better for the editor to provide this type of information (on what to index)
Sometimes I add more than one project folder to editor workspace.
Looking forward to it!🙌

@vinistock
Copy link
Member

I don't understand how files with cerificates, code of conduct, etc. will be helpful for completion.

They aren't indeed, but trying to handle this from the index would mean some sort of allowlist of file extensions, which may not be worth maintaining or at least it's unclear to me at this moment.

If you take a look at the file associations configuration for the VS Code extension, there are numerous extensions that should be associated to Ruby. Which ones should be indexed? For example, what if some .rbx files should be indexed, but not all of them?

Maybe in the future we can be more opinionated about which extensions other than .rb should be indexed automatically, but for now I feel like users are better suited to configure this.

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
None yet
Development

No branches or pull requests

2 participants