How to Directly Install a Gem from a Git Repository

How to install gem from GitHub source?

In case you are using bundler, you need to add something like this to your Gemfile:

gem 'redcarpet', :git => 'git://github.com/tanoku/redcarpet.git'

And in case there is .gemspec file, it should be able to fetch and install the gem when running bundle install.

UPD. As indicated in comments, for Bundler to function properly you also need to add the following to config.ru:

require "bundler" 
Bundler.setup(:default)

Install Gem from Github Branch?

You don't need to build the gem locally. In your gemfile you can specify a github source with a ref, branch or tag.

gem 'rails', git: 'git://github.com/rails/rails.git', ref: '4aded'
gem 'rails', git: 'git://github.com/rails/rails.git', branch: '2-3-stable'
gem 'rails', git: 'git://github.com/rails/rails.git', tag: 'v2.3.5'

Then you run bundle install or the short form is just bundle.

Read more about it here: http://bundler.io/man/gemfile.5.html#GIT

Update: There's a github source identifier.

gem 'country_select', github: 'stefanpenner/country_select'

However, they warn against using it: NOTE: This shorthand should be avoided until Bundler 2.0, since it currently expands to an insecure git:// URL. This allows a man-in-the-middle attacker to compromise your system.

After Bundler 2.0, you can get around the above issue with this statement near the top of the Gemfile:

git_source(:github) { |repo| "https://github.com/#{repo}.git" }

Install ruby gem globally from github repository

  1. Download the source:

    git clone https://github.com/thoughtbot/capybara-webkit.git
  2. Build the gem:

    cd capybara-webkit && gem build capybara-webkit.gemspec
  3. Install it (the filename/version may vary):

    sudo gem install capybara-webkit-0.14.1.gem

How to install the git head of a gem through Rubygems.org?

Is there a way to force a gem to be installed with the latest commit
through Rubygems.org without using Bundler?

The short answer is no, you cannot force-install an unpublished gem through RubyGems.org because RubyGems is a repository for published gems. If the repository owner has pushed a version of the gem to RubyGems you can find and install it. If they haven't, you can't.

If you want to use pre-published code from a repository, use the Bundler method outlined in Semih's answer:

gem 'rails', github: 'rails/rails', branch: 'master'

Per the RubyGems site documentation:

Installing a gem directly from a git repository is a feature of
Bundler, not a feature of RubyGems. Gems installed this way will not
show up when you run gem list.

Installing a Ruby gem from a Github repository using Chef?

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

Install a ruby gem from a local repository

In your local repository:

gem build yourlocalrepo.gemspec

This will create a .gem file.
Now:

gem install yourlocalrepo.gem


Related Topics



Leave a reply



Submit