Is it possible to directly install a gem from a git repository?

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?

  • Deployment using Capistrano + Gitlab using via: remote_cache
  • Ruby: Rails: Which version of a gem is used?
  • Gems not found by 'gem list' when using 'bundle install' for git gems with RVM
  • Is there a gem to make Git and Rails work together for more robust migrations?
  • An error occurred while installing rugged
  • Cannot load Rails app fetched from GitHub; rake, rails server not working
  • 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.

  • Can github boxen run in mac os 10.7 (Lion)
  • Able to recover a deleted branch using git tag
  • git status says up-to-date with remote even though it's not
  • GIT RM a file with a leading whitespace character in filename
  • Interact with remote Mercurial and Git http repositories
  • 403 error when pushing to GitHub
  • One Solution collect form web for “Is it possible to directly install a gem from a git repository?”

    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

    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
    Git Baby is a git and github fan, let's start git clone.