Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Improve gem/gemset not found detection

Newer RVM versions exit with an error status when trying to list
gems and gemsets for a Ruby version that is not installed
  • Loading branch information...
commit f3a6e3302d0441d8890724e932cd7c4f06590576 1 parent 49d8353
@blt04 blt04 authored
View
3  lib/puppet/provider/rvm_gem/gem.rb
@@ -30,6 +30,7 @@ def gemlist(hash)
command << name + "$"
end
+ list = []
begin
list = execute(command).split("\n").collect do |set|
if gemhash = self.class.gemsplit(set)
@@ -40,7 +41,6 @@ def gemlist(hash)
end
end.compact
rescue Puppet::ExecutionFailure => detail
- raise Puppet::Error, "Could not list gems: #{detail}"
end
if hash[:justme]
@@ -53,6 +53,7 @@ def gemlist(hash)
def self.gemsplit(desc)
case desc
when /^\*\*\*/, /^\s*$/, /^\s+/; return nil
+ when /gem: not found/; return nil
when /^(\S+)\s+\(([^ ]+).*\)/
name = $1
version = $2.split(/,\s*/)[0]
View
13 lib/puppet/provider/rvm_gemset/gemset.rb
@@ -21,12 +21,15 @@ def gemsetcommand_force
end
def gemset_list
- list = []
-
command = gemsetcommand + ['list']
- list = execute(command).split("\n").collect do |line|
- line.strip if line =~ /^\s+\S+/
- end.compact
+
+ list = []
+ begin
+ list = execute(command).split("\n").collect do |line|
+ line.strip if line =~ /^\s+\S+/
+ end.compact
+ rescue Puppet::ExecutionFailure => detail
+ end
list
end
Please sign in to comment.
Something went wrong with that request. Please try again.