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

undefined method `strip' for nil:NilClass on last version #329

Closed
gencer opened this issue Jun 7, 2020 · 9 comments
Closed

undefined method `strip' for nil:NilClass on last version #329

gencer opened this issue Jun 7, 2020 · 9 comments

Comments

@gencer
Copy link

gencer commented Jun 7, 2020

I got crash on start. Says;

[Error - 2:52:34 PM] Server initialization failed.
  Message: [NoMethodError] undefined method `strip' for nil:NilClass
  Code: -32603 
@gencer
Copy link
Author

gencer commented Jun 7, 2020

Ah, It seems this happens on master branch. Downgrading to stable fixes the problem.

@castwide
Copy link
Owner

castwide commented Jun 7, 2020

Does it give you a stack trace in the developer console?

@gencer
Copy link
Author

gencer commented Jun 7, 2020

Yes:

[Extension Host] Solargraph is listening PORT=42381 PID=691450
console.ts:137 [Extension Host] [WARN] Failed to load plugin 'runtime'
console.ts:137 [Extension Host] [WARN] Error processing request: [NoMethodError] undefined method `strip' for nil:NilClass
console.ts:137 [Extension Host] [WARN] /home/gencer/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.9/lib/solargraph/source_map/mapper.rb:158:in `process_directive'/home/gencer/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.9/lib/solargraph/source_map/mapper.rb:72:in `block in process_comment'/home/gencer/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.9/lib/solargraph/source_map/mapper.rb:69:in `each'/home/gencer/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.9/lib/solargraph/source_map/mapper.rb:69:in `process_comment'/home/gencer/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.9/lib/solargraph/source_map/mapper.rb:206:in `block in process_comment_directives'/home/gencer/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.9/lib/solargraph/source_map/mapper.rb:203:in `each'/home/gencer/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.9/lib/solargraph/source_map/mapper.rb:203:in `process_comment_directives'/home/gencer/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.9/lib/solargraph/source_map/mapper.rb:27:in `map'/home/gencer/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.9/lib/solargraph/source_map/mapper.rb:50:in `map'/home/gencer/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.9/lib/solargraph/source_map.rb:156:in `map'/home/gencer/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.9/lib/solargraph/api_map.rb:85:in `block in catalog'/home/gencer/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.9/lib/solargraph/api_map.rb:67:in `each'/home/gencer/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.9/lib/solargraph/api_map.rb:67:in `catalog'/home/gencer/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.9/lib/solargraph/library.rb:23:in `initialize'/home/gencer/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.9/lib/solargraph/library.rb:363:in `new'/home/gencer/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.9/lib/solargraph/library.rb:363:in `load'/home/gencer/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.9/lib/solargraph/language_server/host.rb:278:in `prepare'/home/gencer/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.9/lib/solargraph/language_server/host.rb:295:in `block in prepare_folders'/home/gencer/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.9/lib/solargraph/language_server/host.rb:294:in `each'/home/gencer/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.9/lib/solargraph/language_server/host.rb:294:in `prepare_folders'/home/gencer/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.9/lib/solargraph/language_server/message/initialize.rb:14:in `block in process'/home/gencer/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/benchmark-0.1.0/lib/benchmark.rb:293:in `measure'/home/gencer/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.9/lib/solargraph/language_server/message/initialize.rb:10:in `process'/home/gencer/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.9/lib/solargraph/language_server/host.rb:101:in `receive'/home/gencer/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.9/lib/solargraph/language_server/transport/adapter.rb:44:in `process'/home/gencer/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.9/lib/solargraph/language_server/transport/adapter.rb:17:in `block in opening'/home/gencer/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.9/lib/solargraph/language_server/transport/data_reader.rb:59:in `parse_message_from_buffer'/home/gencer/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.9/lib/solargraph/language_server/transport/data_reader.rb:35:in `block in receive'/home/gencer/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.9/lib/solargraph/language_server/transport/data_reader.rb:30:in `each_char'/home/gencer/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.9/lib/solargraph/language_server/transport/data_reader.rb:30:in `receive'/home/gencer/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.9/lib/solargraph/language_server/transport/adapter.rb:27:in `receiving'/home/gencer/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/backport-1.1.2/lib/backport/client.rb:63:in `tick'/home/gencer/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/backport-1.1.2/lib/backport/server/tcpip.rb:76:in `update'/home/gencer/.rbenv/versions/2.6.6/lib/ruby/2.6.0/observer.rb:197:in `block in notify_observers'/home/gencer/.rbenv/versions/2.6.6/lib/ruby/2.6.0/observer.rb:196:in `each'/home/gencer/.rbenv/versions/2.6.6/lib/ruby/2.6.0/observer.rb:196:in `notify_observers'/home/gencer/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/backport-1.1.2/lib/backport/client.rb:121:in `read_input'/home/gencer/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/backport-1.1.2/lib/backport/client.rb:102:in `block in run_input_thread'
notificationsAlerts.ts:40 [NoMethodError] undefined method `strip' for nil:NilClass
onDidChangeNotification @ notificationsAlerts.ts:40
(anonymous) @ notificationsAlerts.ts:26
fire @ event.ts:587
addNotification @ notifications.ts:207
notify @ notificationService.ts:106
(anonymous) @ mainThreadMessageService.ts:83
_showMessage @ mainThreadMessageService.ts:44
$showMessage @ mainThreadMessageService.ts:38
_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] Error starting Solargraph socket provider Error: [NoMethodError] undefined method `strip' for nil:NilClass
	at new ResponseError (/home/gencer/.vscode-server/extensions/castwide.solargraph-0.21.1/node_modules/vscode-languageclient/node_modules/vscode-jsonrpc/lib/messages.js:46:28)
	at handleResponse (/home/gencer/.vscode-server/extensions/castwide.solargraph-0.21.1/node_modules/vscode-languageclient/node_modules/vscode-jsonrpc/lib/main.js:430:48)
	at processMessageQueue (/home/gencer/.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/gencer/.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)
notificationsAlerts.ts:40 Failed to start Solargraph: Error: [NoMethodError] undefined method `strip' for nil:NilClass
onDidChangeNotification @ notificationsAlerts.ts:40
(anonymous) @ notificationsAlerts.ts:26
fire @ event.ts:587
addNotification @ notifications.ts:207
notify @ notificationService.ts:106
(anonymous) @ mainThreadMessageService.ts:83
_showMessage @ mainThreadMessageService.ts:44
$showMessage @ mainThreadMessageService.ts:38
_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

@castwide
Copy link
Owner

castwide commented Jun 7, 2020

Thanks. I suspected it was an issue with a change to @!parse macro handling, and that confirmed it. I'll have a fix in the master branch shortly and it'll be included in the next patch release.

@Syntaf
Copy link

Syntaf commented Jul 1, 2020

👋 I seem to also be running into this issue with the latest release, here's solargraph per my lockfile: See edits below

    solargraph (0.39.10)
      backport (~> 1.1)
      benchmark
      bundler (>= 1.17.2)
      e2mmap
      jaro_winkler (~> 1.5)
      maruku (~> 0.7, >= 0.7.3)
      nokogiri (~> 1.9, >= 1.9.1)
      parser (~> 2.3)
      reverse_markdown (>= 1.0.5, < 3)
      rubocop (~> 0.52)
      thor (~> 1.0)
      tilt (~> 2.0)
      yard (~> 0.9, >= 0.9.24)

In the output tab I'm seeing the following error:

[Error - 4:25:19 PM] Server initialization failed.
  Message: [NoMethodError] undefined method `strip' for nil:NilClass
  Code: -32603 

I unfortunately don't know how to get a stack trace like what @gencer posted. Any recommendations on how to work around this?

If it helps, I'm running the extension inside a container on a codebase with Rails 6 + Ruby 2.7

EDIT: It looks like this error was caused by my rails.rb file, which I originally added after searching for how to add rails definitions. Once I removed this file the error stopped occurring, however I still can't seem to get solargraph to run my linter, working through that atm.

EDIT #2: I had a small syntax error in my rubocop yaml which caused the linter to silently fail 🤦

@jklapacz
Copy link

jklapacz commented Jul 1, 2020

I was having the same problem as @Syntaf, the rails.rb definitions file was causing problems. I removed the explanatory comments and everything worked.
These are the lines I removed:

# The following comments fill some of the gaps in Solargraph's understanding of
# Rails apps. Since they're all in YARD, they get mapped in Solargraph but
# ignored at runtime.
#
# You can put this file anywhere in the project, as long as it gets included in
# the workspace maps. It's recommended that you keep it in a standalone file
# instead of pasting it into an existing one.

@castwide
Copy link
Owner

castwide commented Jul 1, 2020

Thanks, @jklapacz. I confirmed that I get the same error as @Syntaf and that your workaround fixed it.

I have a hunch what the problem is and will release a patch ASAP.

@castwide
Copy link
Owner

castwide commented Jul 1, 2020

Also, @Syntaf: that stack trace came from the developer console (Help -> Toggle Developer Tools).

@castwide
Copy link
Owner

castwide commented Jul 3, 2020

Fix released in v0.39.11.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants