(PUP-6134) Explicitly locate gemcmd windows#5814
(PUP-6134) Explicitly locate gemcmd windows#5814tkishel wants to merge 1 commit intopuppetlabs:4.10.xfrom
Conversation
|
CLA signed by all contributors. |
|
Resubmitted this PR to recover from a rebase error with the previous PR. |
|
Replaces #5460. |
lib/puppet/provider/package/gem.rb
Outdated
| # That results in the which() method in self.command(name) in lib/puppet/provider.rb always returning Puppet's gem command. | ||
| # To prevent this, call which("gem") with a PATH without Puppet's paths, and set gemcmd to the full-path result. | ||
| path_array = Puppet::Util.get_env("PATH").split(File::PATH_SEPARATOR) | ||
| path_array.reject! {|p| p =~ /puppet/i} |
There was a problem hiding this comment.
The method of constructing the PATH is a bit imprecise - a few problems I see:
- What if a user relocated the installation to something without
puppetin it? - What if the Ruby installation path contains
puppetin it? (admittedly less likely)
We can add a little bit of code to find the actual current running Ruby like this:
https://stackoverflow.com/a/25929455
I can help out with putting that in the right spot within Puppet.
There was a problem hiding this comment.
Thanks, I made an assumption that users might change INSTALLDIR from the default of C:\Program Files\Puppet Labs\Puppet but not change that last Puppet directory.
Since we already find and set RUBY_DIR, could we reuse it as follows?
if Puppet.features.microsoft_windows?
ruby_bin_dir = Puppet::Util.get_env('RUBY_DIR') + '\bin'
path_array = Puppet::Util.get_env('PATH').split(File::PATH_SEPARATOR)
path_array.reject! {|p| p == ruby_bin_dir}
path_without_puppet_ruby_bin_dir = path_array.join(File::PATH_SEPARATOR)
commands :gemcmd => Puppet::Util.withenv({:PATH => path_without_puppet_ruby_bin_dir}, :windows) { which('gem') }
else
commands :gemcmd => 'gem'
end
There was a problem hiding this comment.
But if you make that available in another spot, I'll use it.
b9be434 to
e8452af
Compare
1cefba1 to
c28122f
Compare
|
I have rebased onto 4.10.x but have not been able to clear the AppVeyor error. I thought it might be related to line 103 of spec/integration/type/package_spec.rb specifying the provider as A similar error occurs when running I will need help addressing that. Note that manually testing this commit on Windows with |
|
@Iristyle @geoffnichols any advice on how we can troubleshoot the AppVeyor check or who we can ask to help? |
c28122f to
65483fb
Compare
65483fb to
fb576c5
Compare
|
The AppVeyor Windows environment, unlike the Puppet Agent Windows environment, does not define a Resolved for AppVeyor by checking for Note that |
fb576c5 to
c1cd7c6
Compare
On Windows: Puppet is unable to install a ruby gem anywhere other than Puppet's ruby. Caused by Puppet prepending its paths (including our gem) to PATH. This fix removes Puppet's paths from PATH when setting :gemcmd.
c1cd7c6 to
82bcd9e
Compare
|
@caseywilliams @branan is this still an issue with the updates that happened to the MSI paths in puppet 6? |
|
@melissa yeah, nothing about the path updates would have changed this. It would still be an issue. |
|
@Iristyle could you take another look at this? |
|
I understand we may consider this to be a breaking change, as we may have users using this bug as a feature to manage puppet gems on Windows (normally managed via the puppet_gem provider) via the gem provider? |
|
Could someone from @puppetlabs/windows please take a look at this? |
|
Adding @puppetlabs/night-s-watch to review |
|
Looks like this is superseded by the targetable provider work in PUP-6488, so I'm going to close this PR. Please reopen if I've got that wrong. |
On Windows:
Puppet is unable to install a ruby gem anywhere other than Puppet's ruby.
Caused by Puppet prepending its paths (including our gem) to PATH.
This fix removes Puppet's paths from PATH when setting :gemcmd.
(A larger-scale solution would involve a path/target parameter to Package.)