diff --git a/lib/puppet-languageserver/manifest/validation_provider.rb b/lib/puppet-languageserver/manifest/validation_provider.rb index 2daa3298..7034ef56 100644 --- a/lib/puppet-languageserver/manifest/validation_provider.rb +++ b/lib/puppet-languageserver/manifest/validation_provider.rb @@ -109,7 +109,9 @@ def self.init_puppet_lint(root_dir, lint_options = []) linter_options = PuppetLint::OptParser.build else begin - Dir.chdir(root_dir.to_s) { linter_options = PuppetLint::OptParser.build } + $PuppetParserMutex.synchronize do # rubocop:disable Style/GlobalVars + Dir.chdir(root_dir.to_s) { linter_options = PuppetLint::OptParser.build } + end rescue OptionParser::InvalidOption => e PuppetLanguageServer.log_message(:error, "(#{name}) Error reading Puppet Lint configuration. Using default: #{e}") linter_options = PuppetLint::OptParser.build