Install local gems with chef

I’ve done some looking through the docs and the archive of this mail list, but
I’m not seeing anything related to installing gems from a local source using
Chef. The gem command supports a “–local” option which signals it to only use
gems that it finds in the current working directory. I’ve tried using the
options attribute with the package resource while using the gem_package
provider, but looking at the debug output (when I run chef-solo) I see
something like the following: “DEBUG: ---- Begin output of gem install
imagesize -q --no-rdoc --no-ri -v 0.1.1 ----” which does not seem to indicate
that the gem_package provider even recognizes the options atribute. Is this
correct? Will this be added/fixed? Thanks.

John Timms

On Mon, Jul 6, 2009 at 6:31 AM, john@gnoso.com wrote:

I've done some looking through the docs and the archive of this mail list, but
I'm not seeing anything related to installing gems from a local source using
Chef. The gem command supports a "--local" option which signals it to only use
gems that it finds in the current working directory. I've tried using the
options attribute with the package resource while using the gem_package
provider, but looking at the debug output (when I run chef-solo) I see
something like the following: "DEBUG: ---- Begin output of gem install
imagesize -q --no-rdoc --no-ri -v 0.1.1 ----" which does not seem to indicate
that the gem_package provider even recognizes the options atribute. Is this
correct? Will this be added/fixed? Thanks.

We should add local support the Gem provider - it shouldn't be super
hard (but will require a bit of refactoring of load_current_resource
in that provider).

In the meantime, it should be easy to whip up a definition that uses
execute resources to do this for you.

Adam

--
Opscode, Inc.
Adam Jacob, CTO
T: (206) 508-7449 E: adam@opscode.com

Yes- that was my thinking as well- use the execute resources, but that would
loose the feature that keeps gems from being re-installed if they are
already installed. I imagine that this could be overcome with a bit of
"creates..." usage though.

John Timms

On Tue, Jul 7, 2009 at 2:17 PM, Adam Jacob adam@opscode.com wrote:

On Mon, Jul 6, 2009 at 6:31 AM, john@gnoso.com wrote:

I've done some looking through the docs and the archive of this mail
list, but
I'm not seeing anything related to installing gems from a local source
using
Chef. The gem command supports a "--local" option which signals it to
only use
gems that it finds in the current working directory. I've tried using the
options attribute with the package resource while using the gem_package
provider, but looking at the debug output (when I run chef-solo) I see
something like the following: "DEBUG: ---- Begin output of gem install
imagesize -q --no-rdoc --no-ri -v 0.1.1 ----" which does not seem to
indicate
that the gem_package provider even recognizes the options atribute. Is
this
correct? Will this be added/fixed? Thanks.

We should add local support the Gem provider - it shouldn't be super
hard (but will require a bit of refactoring of load_current_resource
in that provider).

In the meantime, it should be easy to whip up a definition that uses
execute resources to do this for you.

Adam

--
Opscode, Inc.
Adam Jacob, CTO
T: (206) 508-7449 E: adam@opscode.com

On Tue, Jul 7, 2009 at 11:20 AM, John Timmsjohn@gnoso.com wrote:

Yes- that was my thinking as well- use the execute resources, but that would
loose the feature that keeps gems from being re-installed if they are
already installed. I imagine that this could be overcome with a bit of
"creates..." usage though.

Right - either that, or a not_if block that does something like:

gem list --local GEMNAME | grep VERSION

Adam

--
Opscode, Inc.
Adam Jacob, CTO
T: (206) 508-7449 E: adam@opscode.com

On Tue, Jul 7, 2009 at 11:20 AM, John Timmsjohn@gnoso.com wrote:

Yes- that was my thinking as well- use the execute resources, but that would
loose the feature that keeps gems from being re-installed if they are
already installed. I imagine that this could be overcome with a bit of
"creates..." usage though.

how about a notif around 'gem query --installed -n PACKAGE'

On Tue, Jul 7, 2009 at 11:27 AM, Bryan McLellanbtm@loftninjas.org wrote:

how about a notif around 'gem query --installed -n PACKAGE'

I bow before your rocking gem-ness.

gem query --installed -n treetop --version 1.2.5
true

gem query --installed -n treetop --version 1.2.6
false

With proper error codes.

Nice one. I think we should start having command golf points for
things like this. :slight_smile:

Adam

--
Opscode, Inc.
Adam Jacob, CTO
T: (206) 508-7449 E: adam@opscode.com

Is my experience correct- the Gem provider does not support the options
attribute?

John Timms

On Tue, Jul 7, 2009 at 2:30 PM, Adam Jacob adam@opscode.com wrote:

On Tue, Jul 7, 2009 at 11:27 AM, Bryan McLellanbtm@loftninjas.org wrote:

how about a notif around 'gem query --installed -n PACKAGE'

I bow before your rocking gem-ness.

gem query --installed -n treetop --version 1.2.5
true

gem query --installed -n treetop --version 1.2.6
false

With proper error codes.

Nice one. I think we should start having command golf points for
things like this. :slight_smile:

Adam

--
Opscode, Inc.
Adam Jacob, CTO
T: (206) 508-7449 E: adam@opscode.com

Correct, as of now.

Ada

On Tue, Jul 7, 2009 at 11:34 AM, John Timmsjohn@gnoso.com wrote:

Is my experience correct- the Gem provider does not support the options
attribute?

John Timms

On Tue, Jul 7, 2009 at 2:30 PM, Adam Jacob adam@opscode.com wrote:

On Tue, Jul 7, 2009 at 11:27 AM, Bryan McLellanbtm@loftninjas.org wrote:

how about a notif around 'gem query --installed -n PACKAGE'

I bow before your rocking gem-ness.

gem query --installed -n treetop --version 1.2.5
true

gem query --installed -n treetop --version 1.2.6
false

With proper error codes.

Nice one. I think we should start having command golf points for
things like this. :slight_smile:

Adam

--
Opscode, Inc.
Adam Jacob, CTO
T: (206) 508-7449 E: adam@opscode.com

--
Opscode, Inc.
Adam Jacob, CTO
T: (206) 508-7449 E: adam@opscode.com