voxpupuli / puppet-python

Puppet module for installing and managing Python, pip, virtualenvs and Gunicorn virtual hosts.
https://forge.puppetlabs.com/puppet/python
Apache License 2.0
199 stars 375 forks source link

"undefined method []" in pip_version and virtualenv_version facts #527

Closed alanwevans closed 4 years ago

alanwevans commented 4 years ago

We ran into a situation where pip and virtualenv were in the PATH on a particular system but referred to a non-existent python installation.

In both cases the facts are generated by using a regex match against the stdout/stderr of the relevant commands. When the regex fails to produce a match it returns nil instead and of course nil doesn't have a [] method.

Affected Puppet, Ruby, OS and module versions/distributions

How to reproduce (e.g Puppet code you use)

Run puppet with the python module on a system with broken pip and/or virtualenv commands.

What are you seeing

Errors:

Error: Facter: error while resolving custom fact "pip_version": undefined method []' for nil:NilClass
Error: Facter: error while resolving custom fact "virtualenv_version": undefined method []' for nil:NilClass

What behaviour did you expect instead

The pip_version and virtualenv_version facts should be nil when their respective commands are broken.