Please review pull request #41: (#14147) Handle lack of rubygems gracefully opened by (haus)
Description:
Hiera previously expected rubygems to be available. When running from source or
a package, rubygems may not be available. This fix rescues the load error on
rubygem and silently ignores it so that if rubygems is present, it can be used,
but if it isn't present, hiera can still function.
(Borrowed the method used in puppet)
- Opened: Tue Apr 24 00:11:52 UTC 2012
- Based on: puppetlabs:master (05ac83eca3137ba183dc43ce4ead855ba18bc075)
- Requested merge: haus:ticket/master/14147_handle_rubygems_gracefully (67f91d65c2c560bd6e7d11c6d9c0691f3f442452)
Diff follows:
diff --git a/bin/hiera b/bin/hiera
index cc4c8a8..a441b1e 100755
--- a/bin/hiera
+++ b/bin/hiera
@@ -11,7 +11,10 @@
#
# $ hiera release 'rel/%{location}' location=dc2 --yaml some.node.yaml
-require 'rubygems'
+begin
+ require 'rubygems'
+rescue LoadError
+end
require 'hiera'
require 'optparse'
diff --git a/lib/hiera.rb b/lib/hiera.rb
index 2afa589..600b8b4 100644
--- a/lib/hiera.rb
+++ b/lib/hiera.rb
@@ -1,4 +1,7 @@
-require 'rubygems'
+begin
+ require 'rubygems'
+rescue LoadError
+end
require 'yaml'
class Hiera
-- You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
