Skip to content

Commit fb4bc1d

Browse files
author
jordanbreen28
committed
(bug) - Add synchronization to Dir.chdir in init_puppet_lint
This commit wraps the `Dir.chdir` call in the `validation_provider.rb` file within a `$PuppetParserMutex.synchronize` block. Before this change, the `Dir.chdir` method was called without synchronization, which could lead to conflicts if another `chdir` block was in progress. This change prevents the error "(puppet/fixDiagnosticErrors) conflicting chdir during another chdir block" by ensuring that the `Dir.chdir` call is only executed by one thread at a time.
1 parent 2a7db14 commit fb4bc1d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/puppet-languageserver/manifest/validation_provider.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ def self.init_puppet_lint(root_dir, lint_options = [])
109109
linter_options = PuppetLint::OptParser.build
110110
else
111111
begin
112-
Dir.chdir(root_dir.to_s) { linter_options = PuppetLint::OptParser.build }
112+
$PuppetParserMutex.synchronize do # rubocop:disable Style/GlobalVars
113+
Dir.chdir(root_dir.to_s) { linter_options = PuppetLint::OptParser.build }
114+
end
113115
rescue OptionParser::InvalidOption => e
114116
PuppetLanguageServer.log_message(:error, "(#{name}) Error reading Puppet Lint configuration. Using default: #{e}")
115117
linter_options = PuppetLint::OptParser.build

0 commit comments

Comments
 (0)