[chef] Re: Re: cookbook lib requiring gem


Chronological Thread 
  • From: Andreas Kollegger < >
  • To:
  • Subject: [chef] Re: Re: cookbook lib requiring gem
  • Date: Wed, 23 Feb 2011 20:08:00 +0100

Perfectly clever. Thanks, guys.

Cheers,
Andreas

On Feb 23, 2011, at 7:35 PM, Joshua Timberman wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hello!
> 
> On Feb 23, 2011, at 11:22 AM, Andreas Kollegger wrote:
> 
>> What's the appropriate way to require a non-standard gem for a cookbook's 
>> library? I'm adding a zip.rb library to my cookbook, but it requires 
>> 'archive/zip' to do the actual work. 
>
>> Should manually installing that gem be a pre-requisite,  or is there a 
>> clever way to bootstrap it with the gem_package resource in the recipe 
>> that uses it? 
>
>> Or, is relying on extra gems frowned upon?
> 
> 
> Not at all frowned on, and it is an encouraged feature of Chef :). In the 
> recipe:
> 
>    g = gem_package "archive-zip" do
>      action :nothing
>    end
> 
>    g.run_action(:install)
>    require 'rubygems'
>    Gem.clear_paths
>    require 'archive/zip'
> 
> You can see an example of this in a few of Opscode's cookbooks, such as 
> 'aws':
> 
> https://github.com/opscode/cookbooks/blob/master/aws/recipes/default.rb
> 
> 
> - -- 
> Opscode, Inc
> Joshua Timberman, Technical Evangelist
> IRC, Skype, Twitter, Github: jtimberman
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (Darwin)
> 
> iEYEARECAAYFAk1lU3UACgkQO97WSdVpzT0+wwCeMwLqaZRpBF7FwmXcLDQK6fW4
> FbIAnA+LHcvMP8AXRUuk0ir+NaXL24SO
> =StRw
> -----END PGP SIGNATURE-----




Archive powered by MHonArc 2.6.16.

§