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

use system puppet-lint / how to install different puppet-lint plugins? #323

Open
bastelfreak opened this issue Feb 15, 2022 · 4 comments
Open

Comments

@bastelfreak
Copy link

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 puppetlabs/puppet-vscode#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?

@bastelfreak
Copy link
Author

Related issues:

Looks like puppet-lint is loaded as a lib in a few places:

linter = PuppetLint::Checks.new
linter.load_data(nil, content)
problems = linter.run(nil, content)
problems_fixed = problems.nil? ? 0 : problems.count { |item| item[:kind] == :fixed }
[problems_fixed, linter.manifest]
end
def self.validate(session_state, content, options = {})
options = {
:max_problems => 100,
:tasks_mode => false
}.merge(options)
result = []
# TODO: Need to implement max_problems
problems = 0
init_puppet_lint(session_state.documents.store_root_path, [])
begin
linter = PuppetLint::Checks.new

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.

@bastelfreak
Copy link
Author

bastelfreak commented Feb 15, 2022

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?

@glennsarti
Copy link
Contributor

@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:

  1. Run puppet-lint out of process of the language server but there's a big performance hit with spinning up ruby processes
  2. 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? 🤷‍♀️

@glennsarti
Copy link
Contributor

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

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

2 participants