Shopify / ruby-lsp

An opinionated language server for Ruby
https://shopify.github.io/ruby-lsp/
MIT License
1.33k stars 118 forks source link

Log invalid JSON environment #2000

Closed vinistock closed 2 weeks ago

vinistock commented 2 weeks ago

Motivation

When something goes wrong with a version manager and they produce an invalid environment JSON, it's hard to debug or understand what's going on. We should log what string we tried to parse so that we can more easily diagnose issues.

Implementation

Created a parseWithErrorHandling helper in the VersionManager parent class, which tries to parse and logs the error if that fails. Then started using it in all version managers.

Automated Tests

Added a test for rbenv only because the behaviour is the same on all other managers.