Skip to content

Commit ed16615

Browse files
GabrielNagylucywyman
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 a59b798 commit ed16615

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
@@ -732,11 +732,7 @@ def generate_types
732732
# Initializes a specified directory as a Bolt project and installs any modules
733733
# specified by the user, along with their dependencies
734734
def initialize_project
735-
# Dir.pwd will return backslashes on Windows, but Pathname always uses
736-
# forward slashes to concatenate paths. This results in paths like
737-
# C:\User\Administrator/modules, which fail module install. This ensure
738-
# forward slashes in the cwd path.
739-
dir = File.expand_path(Dir.pwd)
735+
dir = Dir.pwd
740736
name = options[:object] || File.basename(dir)
741737
if name !~ Bolt::Module::MODULE_NAME_REGEX
742738
if options[:object]

lib/bolt/config.rb

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

8787
def self.system_path
88-
# Lazy-load expensive gem code
89-
require 'win32/dir' if Bolt::Util.windows?
90-
9188
if Bolt::Util.windows?
92-
Pathname.new(File.join(Dir::COMMON_APPDATA, 'PuppetLabs', 'bolt', 'etc'))
89+
Pathname.new(File.join(ENV['ALLUSERSPROFILE'], 'PuppetLabs', 'bolt', 'etc'))
9390
else
9491
Pathname.new(File.join('/etc', 'puppetlabs', 'bolt'))
9592
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)