Search code examples
rubyrubygemschef-infrarbenv

install a private gem systemwide by using chef-rbenv


I'm using [chef-rbenv][1] and install gems systemwide like this:

node/my_server.json

  "rbenv": {
        "rubies": ["2.2.0"],
        "global": "2.2.0",
        "root_path": "/opt/rbenv",
        "gems": {
            "2.2.0": [
                { "name": "activesupport"},
                { "name": "awesome_print"}
            ]
        }
   }

I want to install my private gem my_foo like this. The gem works fine in local environments, by writing Gemfile like this:

gem 'my_foo', :git => 'git@bitbucket.org:ironsand/my_foo.git'
gem 'pry-byebug'

The server root account have access right to the git repository.

I found information that if I install own gem server I can install the gem, but I prefer not to install the gem server.

Is there a way to install private gem by using chef-rbenv?


Solution

  • Ruby's gem can't install gems from a git location. This is a feature of bundler. The chef cookbook you're using, implements a wrapper of rubygems' gem command, not bundler.

    You need to clone the private repo to a directory and build/install the gem yourslef OR pre-build a .gem file (see github's release hosting feature for a nice file hosting functionality that sticks to your private github access management).

    Or just call bundler on the Gemfile you're mentioning.