Skip to content

Commit 3c7e3de

Browse files
committed
(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 04b8aec commit 3c7e3de

3 files changed

Lines changed: 3 additions & 11 deletions

File tree

lib/bolt/cli.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -787,11 +787,7 @@ def generate_types
787787
# Initializes a specified directory as a Bolt project and installs any modules
788788
# specified by the user, along with their dependencies
789789
def initialize_project
790-
# Dir.pwd will return backslashes on Windows, but Pathname always uses
791-
# forward slashes to concatenate paths. This results in paths like
792-
# C:\User\Administrator/modules, which fail module install. This ensure
793-
# forward slashes in the cwd path.
794-
dir = File.expand_path(Dir.pwd)
790+
dir = Dir.pwd
795791
name = options[:object] || File.basename(dir)
796792
if name !~ Bolt::Module::MODULE_NAME_REGEX
797793
if options[:object]

lib/bolt/config.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,8 @@ def self.from_file(configfile, overrides = {})
7474
end
7575

7676
def self.system_path
77-
# Lazy-load expensive gem code
78-
require 'win32/dir' if Bolt::Util.windows?
79-
8077
if Bolt::Util.windows?
81-
Pathname.new(File.join(Dir::COMMON_APPDATA, 'PuppetLabs', 'bolt', 'etc'))
78+
Pathname.new(File.join(ENV['ALLUSERSPROFILE'], 'PuppetLabs', 'bolt', 'etc'))
8279
else
8380
Pathname.new(File.join('/etc', 'puppetlabs', 'bolt'))
8481
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)