12

Using bundler, you can do something like this in the Gemfile:

gem 'my_gem', :git => 'git@github:me/my_gem.git'

That builds the gem in that repo and installs it. Works great. Is it possible to do something similar just using the command-line gem tool? Something like this?

gem install my_gem --git="git@github:me/my_gem.git"

Obviously that command doesn't work, but is there something like it that does? I know I can clone the repo, run a gem build my_gem.gemspec and then a gem install my_gem-1.2.3.gem. But I'm wondering if there is a direct one-liner that hides these intermediate steps behind the scenes.

Ben Lee
  • 52,489
  • 13
  • 125
  • 145

1 Answers1

5

Because unlike typical Git repositories, GitHub builds gems, if the project is hosted on GitHub and the gem is found in the source list then you can add GitHub to your sources list like this:

$ gem sources -a http://gems.github.com

and then later install gems as desired in a single step, like this:

$ sudo gem install username-projectname

Otherwise, there's no one-step solution, and you'll have to do something like this:

  1. download the gem zip/tar file
  2. gem build <gemname>.gemspec
  3. sudo gem install <gemname>-x.x.x.gem
Noah Clark
  • 8,101
  • 14
  • 74
  • 116
  • my gem is not in the source list. it is a private repository. – Ben Lee Oct 19 '11 at 01:19
  • 1
    and the latter solution i already know, as i outlined in my post. i was just wondering if there was a one-liner for the gem command. maybe there isn't. – Ben Lee Oct 19 '11 at 01:20
  • You could write a shell function that you passed arguments to. But, I don't know of any slick one-liners. – Noah Clark Oct 19 '11 at 01:24
  • 19
    http://gems.github.com/ says "We've stopped building gems, check out RubyGems.org.". I think this happened a year or two ago. – Andrew Grimm Oct 19 '11 at 01:56
  • Maybe it would help for you to setup a private gem server? http://guides.rubygems.org/run-your-own-gem-server/ – Ninjaxor Mar 28 '13 at 19:28