Skip to content

Commit 65825da

Browse files
GabrielNagydontlaugh
authored andcommitted
(PUP-10653) Remove dependency on win32/dir
For Puppet 7 we are dropping the `win32/dir` dependency as we only used constants from it, which we replaced with environment variables (see: puppetlabs/puppet#8314). This would become breaking in bolt when it switches to Puppet 7 and the win32 gems are no longer pulled. For AIO bolt, the Puppet change won't break anything since bolt uses its own runtime which still packages the win32 gems, but it would still be an improvement in speed if the dependency is dropped. The `win32/dir` gem also monkey patches some `Dir` methods, most notably `glob` and `pwd` to use backslashes which end up causing more trouble as Ruby uses `/` as the default separator for Windows. Switch to using the `ALLUSERSPROFILE` environment variable instead of the `Dir::COMMON_APPDATA` constant, and remove a `Dir.pwd` workaround. !removal * **Remove dependency on win32/dir** ([PUP-10653](https://tickets.puppetlabs.com/browse/PUP-10653)) Replace the usage of win32/dir constants with environment variables.
1 parent 020b5a9 commit 65825da

2 files changed

Lines changed: 2 additions & 6 deletions

File tree

lib/bolt/config.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,8 @@ def self.bolt_schema
9797
end
9898

9999
def self.system_path
100-
# Lazy-load expensive gem code
101-
require 'win32/dir' if Bolt::Util.windows?
102-
103100
if Bolt::Util.windows?
104-
Pathname.new(File.join(Dir::COMMON_APPDATA, 'PuppetLabs', 'bolt', 'etc'))
101+
Pathname.new(File.join(ENV['ALLUSERSPROFILE'], 'PuppetLabs', 'bolt', 'etc'))
105102
else
106103
Pathname.new(File.join('/etc', 'puppetlabs', 'bolt'))
107104
end

lib/bolt/puppetdb/config.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ class Config
1818
end
1919

2020
def self.default_windows_config
21-
require 'win32/dir'
22-
File.expand_path(File.join(Dir::COMMON_APPDATA, 'PuppetLabs/client-tools/puppetdb.conf'))
21+
File.expand_path(File.join(ENV['ALLUSERSPROFILE'], 'PuppetLabs/client-tools/puppetdb.conf'))
2322
end
2423

2524
def self.load_config(options, project_path = nil)

0 commit comments

Comments
 (0)