Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install Gem from Github Branch?

In my gemfile I have this:

gem "authlogic", :git => "git://github.com/odorcicd/authlogic.git", :branch => "rails3" 

How do I install that as a gem so I can test it?

like image 485
Lance Avatar asked May 12 '10 23:05

Lance


People also ask

How do I install gems?

To install a gem, use gem install [gem] . Browsing installed gems is done with gem list . For more information about the gem command, see below or head to RubyGems' docs. There are other sources of libraries though.

How do I install a downloaded gem file?

In the console be located in the gems cache (cd [Ruby Installation version]/lib/ruby/gems/[Ruby version]/cache ) and fire the gem install anygemwithdependencieshere (by example cucumber-2.99. 0 )

How do I install a specific version of a gem?

Use `gem install -v` You may already be familiar with gem install , but if you add the -v flag, you can specify the version of the gem to install. Using -v you can specify an exact version or use version comparators.


2 Answers

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" } 
like image 50
Archonic Avatar answered Sep 19 '22 01:09

Archonic


  1. Clone the Git repository.

    $ git clone git://github.com/odorcicd/authlogic.git 
  2. Change to the new directory.

    cd authlogic 
  3. Checkout branch

    $ git checkout -b rails3 remotes/origin/rails3 
  4. Build the gem.

    $ rake build gem 
  5. Install the gem.

    $ gem install pkg/gemname-1.23.gem 
like image 29
janic_ Avatar answered Sep 17 '22 01:09

janic_