castwide/solargraph

"Request textDocument/definition failed" from Hanami project

Closed this issue · 4 comments

Prerequisites

My environment:

  • System: MacOS 13.4.1
  • Ruby: 3.2.1
  • Solargraph: 0.49.0
  • Hanami: 2.0.3

How to reproduce

  1. Generate a new project using Hanami CLI: hanami new web
  2. Open project using vscode and relevant extension: https://github.com/castwide/vscode-solargraph
  3. You should see the error from Output panel:
[Error - 10:23:10 PM] Request textDocument/definition failed.
  Message: [NoMethodError] undefined method `filename' for ["/Users/dkruban/Development/web/lib"]:Array
  Code: -32603 

In order to save your time I published it: https://github.com/RuBAN-GT/hanami-example

Problem place

  • lib/solargraph/library.rb:278
    When locate_ref method of Library#locate_ref can't find the appropriate location it responds with the workspace variable content (array), therefore Definition#require_location raises above error.

Ideas

The most quickest fix - is returns nil when workspace doesn't have needed location, but it still doesn't have any result. So it's just hotfix.

I am also having this problem

Looks like there are others as well

#686

Fixed on master. The fix will be included in the next gem release later this month.

Released in v0.50.0.