Jira (PUP-9647) Pip package provider should use execute for Windows compatibility

0 views
Skip to first unread message

Sean Millichamp (JIRA)

unread,
Apr 17, 2019, 4:40:04 PM4/17/19
to puppe...@googlegroups.com
Sean Millichamp created an issue
 
Puppet / Bug PUP-9647
Pip package provider should use execute for Windows compatibility
Issue Type: Bug Bug
Affects Versions: PUP 6.4.0, PUP 5.5.10
Assignee: Unassigned
Components: Types and Providers
Created: 2019/04/17 1:39 PM
Priority: Normal Normal
Reporter: Sean Millichamp

The package pip provider has some suggestion of Windows support. However, it uses "execpipe" to invoke commands, which puts a shell redirection of "2>&1" into the final command which is not compatible with Windows.

On a Windows system with Python installed when the "pip_version" method is called it results in an error: "Cannot collect packages for Puppet::Type::Package::ProviderPip3 provider; undefined method `[]' for nil:NilClass"

Reworking this in terms of execute allows the pip provider to work on Windows as well.

 

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Sean Millichamp (JIRA)

unread,
Apr 17, 2019, 5:00:03 PM4/17/19
to puppe...@googlegroups.com

Jarret Lavallee (JIRA)

unread,
Apr 17, 2019, 5:09:03 PM4/17/19
to puppe...@googlegroups.com
Jarret Lavallee updated an issue
 
Change By: Jarret Lavallee
Labels: maintenance triage
Team: Puppet Romania
Method Found: Needs Assessment Customer Feedback

Sean Millichamp (JIRA)

unread,
Jun 1, 2019, 9:30:04 AM6/1/19
to puppe...@googlegroups.com

Josh Cooper (JIRA)

unread,
Jun 25, 2019, 2:26:05 PM6/25/19
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-9647

I think the issue occurs if pip --version returns output that doesn't match the expected regex. To repro, created pip executable shell script in current working directory:

#!/bin/sh
echo whoops

PATH=.:$PATH bundle exec puppet apply -e "package { 'foo': provider => pip }" --trace
Notice: Compiled catalog for neptune in environment production in 0.02 seconds
Error: Failed to apply catalog: undefined method `[]' for nil:NilClass
/Users/josh/work/puppet/lib/puppet/provider/package/pip.rb:73:in `block (2 levels) in pip_version'
/Users/josh/work/puppet/lib/puppet/provider/package/pip.rb:72:in `each'
/Users/josh/work/puppet/lib/puppet/provider/package/pip.rb:72:in `collect'
/Users/josh/work/puppet/lib/puppet/provider/package/pip.rb:72:in `block in pip_version'
/Users/josh/work/puppet/lib/puppet/util/execution.rb:81:in `block (2 levels) in execpipe'
/usr/local/Cellar/rbenv/1.1.2/versions/2.3.8/lib/ruby/2.3.0/open-uri.rb:37:in `open'
/usr/local/Cellar/rbenv/1.1.2/versions/2.3.8/lib/ruby/2.3.0/open-uri.rb:37:in `open'
/Users/josh/work/puppet/lib/puppet/util/execution.rb:80:in `block in execpipe'
/Users/josh/work/puppet/lib/puppet/util.rb:129:in `withenv'
/Users/josh/work/puppet/lib/puppet/util/execution.rb:79:in `execpipe'
/Users/josh/work/puppet/lib/puppet/provider.rb:117:in `execpipe'
/Users/josh/work/puppet/lib/puppet/provider/package/pip.rb:71:in `pip_version'
/Users/josh/work/puppet/lib/puppet/provider/package/pip.rb:35:in `instances'

Since the pip provider combines stdout and stderr, it's possible something is being written to stderr. This can be simulated using:

#!/bin/sh
echo whoops >/dev/stderr
echo pip 1.2.3

The pip provider shouldn't assume each line of output from pip --version matches the regex, see https://github.com/puppetlabs/puppet/blob/179bd10781978ac631eb13fd5b311b420e2c609c/lib/puppet/provider/package/pip.rb#L45

Sean Millichamp (JIRA)

unread,
Jun 26, 2019, 8:30:02 PM6/26/19
to puppe...@googlegroups.com

I dig a bit more digging around. I believe this is the output I'm getting which is causing the version match to fail:

'C:/Program' is not recognized as an internal or external command,
{{ operable program or batch file.}}

The actual path (as returned by Puppet::Util.which('pip.exe')) is "C:/Program Files/Python35/Scripts/pip.exe"

It looks like the command returned needs to have double-quotes around it for it to work properly on Windows, and the double quotes don't seem to negatively affect running it on Linux.

Reply all
Reply to author
Forward
0 new messages