From 2386a599ca6a8ed6c84899156752c89a557c0623 Mon Sep 17 00:00:00 2001 From: lcampbell Date: Sat, 12 May 2012 06:10:02 -0500 Subject: [PATCH 1/2] Catch exception when pip not already installed When pip is not already installed, `current_installed_version` throws an uncaught `Mixlib::ShellOut::ShellCommandFailed`. It tries to catch a `Chef::Exceptions::ShellCommandFailed`, but that doesn't work. This patch makes it unconditionally return `nil` if an exception occurs, so that pip can be installed properly. There's probably a better way to fix this, but alas, I am not well-versed in Ruby. --- providers/pip.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/providers/pip.rb b/providers/pip.rb index 0a559de..3a64fa2 100644 --- a/providers/pip.rb +++ b/providers/pip.rb @@ -126,7 +126,7 @@ def current_installed_version end p = shell_out!(version_check_cmd) p.stdout.split(delimeter)[1].strip - rescue Chef::Exceptions::ShellCommandFailed + else end end From bbff51b7f9637ea05a342a7533505f1ea6bc46f7 Mon Sep 17 00:00:00 2001 From: lcampbell Date: Sat, 12 May 2012 06:39:11 -0500 Subject: [PATCH 2/2] Apparently, `else` doesn't do anything without a `rescue` block. So just use a `rescue`. --- providers/pip.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/providers/pip.rb b/providers/pip.rb index 3a64fa2..10d440f 100644 --- a/providers/pip.rb +++ b/providers/pip.rb @@ -126,7 +126,7 @@ def current_installed_version end p = shell_out!(version_check_cmd) p.stdout.split(delimeter)[1].strip - else + rescue end end