Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing a Ruby gem from a Github repository using Chef?

Is there a way to install a Ruby gem from its Github repo (or, more specifically, a fork) instead of from Rubygems?

I tried

 gem_package 'some_gem' do
  source 'git://github.com:user/some_gem.git'
end

and I get

Gem::Exception
--------------
Cannot load gem at [git://github.com:user/some_gem.git] in /


Resource Declaration:
---------------------
# In /tmp/vagrant-chef-1/chef-solo-1/cookbooks/some_recipe/recipes/default.rb

 15: gem_package 'some_gem' do
 16:   source 'git://github.com:user/some_gem.git'
 17: end
 18: 



Compiled Resource:
------------------
# Declared in /tmp/vagrant-chef-1/chef-solo-1/cookbooks/some_gem/recipes/default.rb:15:in `from_file'

gem_package("some_gem") do
  provider Chef::Provider::Package::Rubygems
  action :install
  retries 0
  retry_delay 2
  package_name "some_gem"
  source "git://github.com:user/some_gem.git"
  cookbook_name :some_cookbook
  recipe_name "default"
end

I also tried the same with the source https://github.com/user/some_gem with the error Illformed requirement [""].

like image 928
apocryphalauthor Avatar asked Oct 14 '13 19:10

apocryphalauthor


2 Answers

I'm not sure that this is the best way to accomplish the task, but I was able get it done this way:

# temporarily install gem from fork
git '/usr/local/src/mosql' do
  repository 'https://github.com/roadtrippers/mosql.git'
end

execute 'gem build mosql.gemspec' do
  cwd '/usr/local/src/mosql'
end

gem_package 'mosql' do
  source '/usr/local/src/mosql/mosql-0.2.0.gem'
end

Where mosql was the name of the forked gem that I was installing.

Caveats here are that the version is put into the .gem file's name, so I had to know that in advance.

like image 60
apocryphalauthor Avatar answered Nov 08 '22 22:11

apocryphalauthor


Quite old question, but you can use http://community.opscode.com/cookbooks/gem_specific_install

I don't maintain it actively, but I'm quite open to new PR

like image 5
Guilhem Avatar answered Nov 08 '22 21:11

Guilhem