castwide / vscode-solargraph

A Visual Studio Code extension for Solargraph.
Other
425 stars 23 forks source link

No implicit conversion of nil into String - ActiveRecord::Base query #188

Open Syntaf opened 4 years ago

Syntaf commented 4 years ago

I'm running the latest solargraph gem version (0.39.13) and noticed the language server responds with an error when trying to query for the ActiveRecord::Base document:

[Extension Host] [INFO] Server received $/solargraph/document[DEBUG] {"jsonrpc"=>"2.0", "id"=>168, "method"=>"$/solargraph/document", "params"=>{"query"=>"ActiveRecord::Base"}}
console.ts:137 [Extension Host] [WARN] Error processing request: [TypeError] no implicit conversion of nil into String
console.ts:137 [Extension Host] [WARN] /usr/local/lib/ruby/2.7.0/rdoc/markup/formatter.rb:25:in `dirname'/usr/local/lib/ruby/2.7.0/rdoc/markup/formatter.rb:25:in `gen_relative_url'/usr/local/lib/ruby/2.7.0/rdoc/markup/formatter.rb:251:in `parse_url'/usr/local/lib/ruby/2.7.0/rdoc/markup/to_html.rb:318:in `gen_url'/usr/local/lib/ruby/2.7.0/rdoc/markup/to_html.rb:115:in `handle_regexp_HYPERLINK'/usr/local/lib/ruby/2.7.0/rdoc/markup/formatter.rb:159:in `block in convert_regexp_handling'/usr/local/lib/ruby/2.7.0/rdoc/markup/attributes.rb:66:in `block in each_name_of'/usr/local/lib/ruby/2.7.0/rdoc/markup/attributes.rb:63:in `each'/usr/local/lib/ruby/2.7.0/rdoc/markup/attributes.rb:63:in `each_name_of'/usr/local/lib/ruby/2.7.0/rdoc/markup/formatter.rb:155:in `convert_regexp_handling'/usr/local/lib/ruby/2.7.0/rdoc/markup/formatter.rb:138:in `block in convert_flow'/usr/local/lib/ruby/2.7.0/rdoc/markup/formatter.rb:130:in `each'/usr/local/lib/ruby/2.7.0/rdoc/markup/formatter.rb:130:in `convert_flow'/usr/local/lib/ruby/2.7.0/rdoc/markup/to_html.rb:400:in `to_html'/usr/local/lib/ruby/2.7.0/rdoc/markup/to_html.rb:189:in `accept_paragraph'/usr/local/bundle/gems/yard-0.9.25/lib/yard/templates/helpers/markup/rdoc_markup.rb:104:in `accept_paragraph'/usr/local/lib/ruby/2.7.0/rdoc/markup/paragraph.rb:11:in `accept'/usr/local/lib/ruby/2.7.0/rdoc/markup/formatter.rb:75:in `block in accept_document'/usr/local/lib/ruby/2.7.0/rdoc/markup/formatter.rb:70:in `each'/usr/local/lib/ruby/2.7.0/rdoc/markup/formatter.rb:70:in `accept_document'/usr/local/lib/ruby/2.7.0/rdoc/markup/document.rb:68:in `accept'/usr/local/lib/ruby/2.7.0/rdoc/markup.rb:822:in `convert'/usr/local/bundle/gems/yard-0.9.25/lib/yard/templates/helpers/markup/rdoc_markup.rb:54:in `block in to_html'/usr/local/bundle/gems/yard-0.9.25/lib/yard/templates/helpers/markup/rdoc_markup.rb:52:in `synchronize'/usr/local/bundle/gems/yard-0.9.25/lib/yard/templates/helpers/markup/rdoc_markup.rb:52:in `to_html'/usr/local/bundle/gems/solargraph-0.39.13/lib/solargraph/page.rb:26:in `htmlify'/usr/local/bundle/gems/solargraph-0.39.13/lib/solargraph/views/_namespace.erb:4:in `__tilt_866280'/usr/local/bundle/gems/tilt-2.0.10/lib/tilt/template.rb:170:in `call'/usr/local/bundle/gems/tilt-2.0.10/lib/tilt/template.rb:170:in `evaluate'/usr/local/bundle/gems/tilt-2.0.10/lib/tilt/template.rb:109:in `render'/usr/local/bundle/gems/solargraph-0.39.13/lib/solargraph/page.rb:59:in `block in initialize'/usr/local/bundle/gems/solargraph-0.39.13/lib/solargraph/page.rb:19:in `block in initialize'/usr/local/bundle/gems/solargraph-0.39.13/lib/solargraph/views/document.erb:19:in `block in __tilt_866280'/usr/local/bundle/gems/solargraph-0.39.13/lib/solargraph/views/document.erb:1:in `each'/usr/local/bundle/gems/solargraph-0.39.13/lib/solargraph/views/document.erb:1:in `__tilt_866280'/usr/local/bundle/gems/tilt-2.0.10/lib/tilt/template.rb:170:in `call'/usr/local/bundle/gems/tilt-2.0.10/lib/tilt/template.rb:170:in `evaluate'/usr/local/bundle/gems/tilt-2.0.10/lib/tilt/template.rb:109:in `render'/usr/local/bundle/gems/solargraph-0.39.13/lib/solargraph/page.rb:56:in `block (2 levels) in initialize'/home/user/.vscode-server/extensions/castwide.solargraph-0.21.1/views/layout.erb:42:in `__tilt_866280'/usr/local/bundle/gems/tilt-2.0.10/lib/tilt/template.rb:170:in `call'/usr/local/bundle/gems/tilt-2.0.10/lib/tilt/template.rb:170:in `evaluate'/usr/local/bundle/gems/tilt-2.0.10/lib/tilt/template.rb:109:in `render'/usr/local/bundle/gems/solargraph-0.39.13/lib/solargraph/page.rb:55:in `block in initialize'/usr/local/bundle/gems/solargraph-0.39.13/lib/solargraph/page.rb:69:in `render'/usr/local/bundle/gems/solargraph-0.39.13/lib/solargraph/language_server/message/extended/document.rb:11:in `process'/usr/local/bundle/gems/solargraph-0.39.13/lib/solargraph/language_server/host.rb:101:in `receive'/usr/local/bundle/gems/solargraph-0.39.13/lib/solargraph/language_server/transport/adapter.rb:44:in `process'/usr/local/bundle/gems/solargraph-0.39.13/lib/solargraph/language_server/transport/adapter.rb:17:in `block in opening'/usr/local/bundle/gems/solargraph-0.39.13/lib/solargraph/language_server/transport/data_reader.rb:59:in `parse_message_from_buffer'/usr/local/bundle/gems/solargraph-0.39.13/lib/solargraph/language_server/transport/data_reader.rb:35:in `block in receive'/usr/local/bundle/gems/solargraph-0.39.13/lib/solargraph/language_server/transport/data_reader.rb:30:in `each_char'/usr/local/bundle/gems/solargraph-0.39.13/lib/solargraph/language_server/transport/data_reader.rb:30:in `receive'/usr/local/bundle/gems/solargraph-0.39.13/lib/solargraph/language_server/transport/adapter.rb:27:in `receiving'/usr/local/bundle/gems/backport-1.1.2/lib/backport/client.rb:63:in `tick'/usr/local/bundle/gems/backport-1.1.2/lib/backport/server/tcpip.rb:76:in `update'/usr/local/lib/ruby/2.7.0/observer.rb:197:in `block in notify_observers'/usr/local/lib/ruby/2.7.0/observer.rb:196:in `each'/usr/local/lib/ruby/2.7.0/observer.rb:196:in `notify_observers'/usr/local/bundle/gems/backport-1.1.2/lib/backport/client.rb:121:in `read_input'/usr/local/bundle/gems/backport-1.1.2/lib/backport/client.rb:102:in `block in run_input_thread'[INFO] Sending response to $/solargraph/document[DEBUG] Content-Length: 116

{"jsonrpc":"2.0","id":168,"error":{"code":-32603,"message":"[TypeError] no implicit conversion of nil into String"}}[INFO] Server received textDocument/hover[DEBUG] {"jsonrpc"=>"2.0", "id"=>169, "method"=>"textDocument/hover", "params"=>{"textDocument"=>{"uri"=>"file:///opt/app/slacklinegroups/db/seeds.rb"}, "position"=>{"line"=>9, "character"=>66}}}
console.ts:137 [Extension Host] [INFO] Sending response to textDocument/hover
console.ts:137 [Extension Host] [DEBUG] Content-Length: 79

{"jsonrpc":"2.0","id":169,"result":{"contents":{"kind":"markdown","value":""}}}
console.ts:137 [Extension Host] rejected promise not handled within 1 second: Error: [TypeError] no implicit conversion of nil into String
t.log @ console.ts:137
$logExtensionHostMessage @ mainThreadConsole.ts:39
_doInvokeHandler @ rpcProtocol.ts:402
_invokeHandler @ rpcProtocol.ts:387
_receiveRequest @ rpcProtocol.ts:303
_receiveOneMessage @ rpcProtocol.ts:230
(anonymous) @ rpcProtocol.ts:105
fire @ event.ts:587
fire @ ipc.net.ts:453
_receiveMessage @ ipc.net.ts:733
(anonymous) @ ipc.net.ts:592
fire @ event.ts:587
acceptChunk @ ipc.net.ts:239
(anonymous) @ ipc.net.ts:200
t @ ipc.net.ts:28
emit @ events.js:203
addChunk @ _stream_readable.js:295
readableAddChunk @ _stream_readable.js:276
Readable.push @ _stream_readable.js:210
onStreamRead @ internal/stream_base_commons.js:166
console.ts:137 [Extension Host] stack trace: Error: [TypeError] no implicit conversion of nil into String   at new ResponseError (/home/user/.vscode-server/extensions/castwide.solargraph-0.21.1/node_modules/vscode-languageclient/node_modules/vscode-jsonrpc/lib/messages.js:46:28) at handleResponse (/home/user/.vscode-server/extensions/castwide.solargraph-0.21.1/node_modules/vscode-languageclient/node_modules/vscode-jsonrpc/lib/main.js:430:48)   at processMessageQueue (/home/user/.vscode-server/extensions/castwide.solargraph-0.21.1/node_modules/vscode-languageclient/node_modules/vscode-jsonrpc/lib/main.js:258:17)  at Immediate.<anonymous> (/home/user/.vscode-server/extensions/castwide.solargraph-0.21.1/node_modules/vscode-languageclient/node_modules/vscode-jsonrpc/lib/main.js:242:13)    at processImmediate (internal/timers.js:439:21)
t.log @ console.ts:137
$logExtensionHostMessage @ mainThreadConsole.ts:39
_doInvokeHandler @ rpcProtocol.ts:402
_invokeHandler @ rpcProtocol.ts:387
_receiveRequest @ rpcProtocol.ts:303
_receiveOneMessage @ rpcProtocol.ts:230
(anonymous) @ rpcProtocol.ts:105
fire @ event.ts:587
fire @ ipc.net.ts:453
_receiveMessage @ ipc.net.ts:733
(anonymous) @ ipc.net.ts:592
fire @ event.ts:587
acceptChunk @ ipc.net.ts:239
(anonymous) @ ipc.net.ts:200
t @ ipc.net.ts:28
emit @ events.js:203
addChunk @ _stream_readable.js:295
readableAddChunk @ _stream_readable.js:276
Readable.push @ _stream_readable.js:210
onStreamRead @ internal/stream_base_commons.js:166
mainThreadExtensionService.ts:65 [[object Object]][TypeError] no implicit conversion of nil into String
$onExtensionRuntimeError @ mainThreadExtensionService.ts:65
_doInvokeHandler @ rpcProtocol.ts:402
_invokeHandler @ rpcProtocol.ts:387
_receiveRequest @ rpcProtocol.ts:303
_receiveOneMessage @ rpcProtocol.ts:230
(anonymous) @ rpcProtocol.ts:105
fire @ event.ts:587
fire @ ipc.net.ts:453
_receiveMessage @ ipc.net.ts:733
(anonymous) @ ipc.net.ts:592
fire @ event.ts:587
acceptChunk @ ipc.net.ts:239
(anonymous) @ ipc.net.ts:200
t @ ipc.net.ts:28
emit @ events.js:203
addChunk @ _stream_readable.js:295
readableAddChunk @ _stream_readable.js:276
Readable.push @ _stream_readable.js:210
onStreamRead @ internal/stream_base_commons.js:166
mainThreadExtensionService.ts:66 Error: [TypeError] no implicit conversion of nil into String
    at new ResponseError (/home/user/.vscode-server/extensions/castwide.solargraph-0.21.1/node_modules/vscode-languageclient/node_modules/vscode-jsonrpc/lib/messages.js:46)
    at handleResponse (/home/user/.vscode-server/extensions/castwide.solargraph-0.21.1/node_modules/vscode-languageclient/node_modules/vscode-jsonrpc/lib/main.js:430)
    at processMessageQueue (/home/user/.vscode-server/extensions/castwide.solargraph-0.21.1/node_modules/vscode-languageclient/node_modules/vscode-jsonrpc/lib/main.js:258)
    at Immediate.<anonymous> (/home/user/.vscode-server/extensions/castwide.solargraph-0.21.1/node_modules/vscode-languageclient/node_modules/vscode-jsonrpc/lib/main.js:242)
    at processImmediate (internal/timers.js:439)

Any ideas? Here's my .solargraph.yml file:

include:
  - ./**/*.rb
exclude:
  - vendor/**/*
  - test/**/*
  - spec/**/*
require:
  - actioncable
  - actionmailer
  - actionpack
  - actionview
  - activejob
  - activemodel
  - activerecord
  - activestorage
  - activesupport
reporters:
  - rubocop

And here's my rails.rb file:

# @!parse
#   class ActionController::Base
#     include ActionController::MimeResponds
#     extend ActiveSupport::Callbacks::ClassMethods
#     extend AbstractController::Callbacks::ClassMethods
#   end
#   class ActiveRecord::Base
#     extend ActiveRecord::QueryMethods
#     extend ActiveRecord::FinderMethods
#     extend ActiveRecord::Associations::ClassMethods
#     include ActiveRecord::Persistence
#   end
castwide commented 4 years ago

Do you still get this error with gem 0.39.14? I haven't been able to reproduce it.

Syntaf commented 4 years ago

@castwide I tried updating to 0.39.14 but no luck it seems.

After updating, I ran Solargraph: Rebuild all Gem Documenation but still had the issue, so I went into the terminal and ran solargraph bundle but that also didn't seem to work.

I thought maybe my rails.rb file was the issue so I also removed that, but it still seems to error trying to load solargraph:/document?query%3DActiveRecord%3A%3ABase

I did notice these errors on my ruby language server output tab when I visited the definition file (i.e. /usr/local/bundle/gems/activerecord-6.0.3.2/lib/active_record/base.rb)

[Error - 10:33:46 PM] Request textDocument/definition failed.
  Message: [Solargraph::Parser::SyntaxError] syntax error, unexpected `do'
  Code: -32603 
[Error - 10:33:46 PM] Request textDocument/hover failed.
  Message: [Solargraph::Parser::SyntaxError] syntax error, unexpected `do'
  Code: -32603 
[Error - 10:33:47 PM] Request textDocument/hover failed.
  Message: [Solargraph::Parser::SyntaxError] syntax error, unexpected `in'
  Code: -32603

Seems like something inside this file is causing the language server to have issues maybe