use system puppet-lint / how to install different puppet-lint plugins?
Describe the Change You Would Like
I guess it's not a bug, just a missing piece in the docs / I'm too stupid to find it:
Hi! I'm working on a windows 10 box with ruby 2.5 / puppet-lint installed as gem. In addition I've a dozen puppet-lint plugins and enable/disable them per module with an individual .puppet-lint.rc (sse https://github.com/puppetlabs/puppet-vscode/issues/804 ). My understanding for the Rakefile in this module is, that puppet-lint is vendored. is that correct? How would I customize the plugins / is it possible to configure the path to puppet-lint?
Related issues:
- https://github.com/puppetlabs/puppet-editor-services/issues/43
- https://github.com/puppetlabs/puppet-editor-services/issues/208
Looks like puppet-lint is loaded as a lib in a few places:
https://github.com/puppetlabs/puppet-editor-services/blob/926c2e074f38d2f0b78ad32bf131b7c1f7862b8d/lib/puppet-languageserver/manifest/validation_provider.rb#L17-L39
https://github.com/puppetlabs/puppet-editor-services/blob/926c2e074f38d2f0b78ad32bf131b7c1f7862b8d/lib/puppet-languageserver/manifest/format_on_type_provider.rb#L25
which makes it real hard to switch to an external puppet-lint implementation. I didn't yet figure out in which Ruby context the language server is executed/how we could easily add more plugins to that.
Given that puppet-lint is not vendored as gem and use siteloaded by modifying the Ruby LOAD path, it should be easy to deploy gems next to it and load them as well?
@bastelfreak So.... it's tricky (tm) 😄
Yes, puppet-lint is vendored into the editor-service and loaded via manipulating the LOAD_PATH (https://github.com/puppetlabs/puppet-editor-services/blob/main/puppet-languageserver#L7)
And adding other puppet-lint gems is possible!
However, the tricky part is "unloading". Because we used puppet-lint as a library (for speed purposes) we can't "unload" puppet-lint gems when users disable/enable them in puppet-lint.rc (Yes I know puppet-lint.rc has issues still in that linked ticket)
So we could:
- Run puppet-lint out of process of the language server but there's a big performance hit with spinning up ruby processes
- May have to run a long-running linting process and the language server can talk to it over some kind of inter-process RPC calls. And then when puppet-lint.rc is modified it can restart the helper process
But both of these will require, not an insignificant amount of work.
As a workaround, I think you can set GEM_PATH prior to running VSCode process, and the language server creation inside VSCode should pass that through .. maybe? 🤷♀️
As a workaround, I think you can set GEM_PATH prior to running VSCode process, and the language server creation inside VSCode should pass that through .. maybe? 🤷♀️
Looks like it doesn't 😭 https://github.com/puppetlabs/puppet-vscode/blob/main/src/helpers/commandHelper.ts#L199-L229