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

Language Server should gracefully fail if Puppet gem cannot be found #118

Closed
glennsarti opened this issue Mar 26, 2019 · 0 comments · Fixed by #134
Closed

Language Server should gracefully fail if Puppet gem cannot be found #118

glennsarti opened this issue Mar 26, 2019 · 0 comments · Fixed by #134

Comments

@glennsarti
Copy link
Contributor

It is possible to start the language server using the system ruby, but it will not contain the puppet gem.

This can happen on Linux/MacOS when the puppet agent is not installed.

Perhaps the language server should gracefully close if it cannot find required dependent gems and not spit out errors like:

[Info  - 1:53:56 pm] Connection to server got closed. Server will restart.
/usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require': cannot load such file -- puppet (LoadError)
	from /usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
	from /home/administrator/puppet-vscode/vendor/languageserver/lib/puppet_languageserver.rb:34:in `require_gems'
	from /home/administrator/puppet-vscode/vendor/languageserver/lib/puppet_languageserver.rb:165:in `init_puppet'
	from /home/administrator/puppet-vscode/vendor/languageserver/puppet-languageserver:10:in `<main>'
[Info  - 1:53:56 pm] Connection to server got closed. Server will restart.
/usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require': cannot load such file -- puppet (LoadError)
	from /usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
	from /home/administrator/puppet-vscode/vendor/languageserver/lib/puppet_languageserver.rb:34:in `require_gems'
	from /home/administrator/puppet-vscode/vendor/languageserver/lib/puppet_languageserver.rb:165:in `init_puppet'
	from /home/administrator/puppet-vscode/vendor/languageserver/puppet-languageserver:10:in `<main>'
[Error - 1:53:56 pm] Connection to server got closed. Server will not be restarted.
glennsarti added a commit to glennsarti/puppet-editor-services that referenced this issue May 27, 2019
Previously the language server would crash/terminate early if a critical gem
like puppet was unavailable.  This can happen when the ruby environment is not
from the Puppet Agent or PDK.  This commit changes the behaviour of the
Language Server to still execute but it a completely disable fashion:

* Detects a failed gem load for critical gems and sets
  PuppetLanguageServer.active? is to false
* When the Language Server is not active, a different Message Router is used
  which effectively warns the user that the server failed to start and that
  all functions are disabled. The server responds to the client with no
  capabilities and the custom getVersion request, is responded to with
  unknown data
glennsarti added a commit to glennsarti/puppet-editor-services that referenced this issue May 27, 2019
Previously the language server would crash/terminate early if a critical gem
like puppet was unavailable.  This can happen when the ruby environment is not
from the Puppet Agent or PDK.  This commit changes the behaviour of the
Language Server to still execute but it a completely disable fashion:

* Detects a failed gem load for critical gems and sets
  PuppetLanguageServer.active? is to false
* When the Language Server is not active, a different Message Router is used
  which effectively warns the user that the server failed to start and that
  all functions are disabled. The server responds to the client with no
  capabilities and the custom getVersion request, is responded to with
  unknown data

No automated tests were added as this is an edge case.  Manual testing was
performed by changing the call `require 'puppet'` to `require 'puppetxxxxx'`
which is enough to trigger a failure.
jpogran pushed a commit that referenced this issue May 28, 2019
(GH-118) Fail gracefully when critical gems cannot load
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

Successfully merging a pull request may close this issue.

1 participant