Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell the Gem File to use a specific local copy of a gem

Say I have a gem living happily at:

  1. /MyPath/MyGem.gem

And I want to use the local and unique gem rather than a gem version from Github, or wherever it fetches it from.

How do I specify I want to use gem "mygem" from /MyPath/MyGem.gem

like image 861
JZ. Avatar asked Jun 02 '11 21:06

JZ.


People also ask

How do I install specific versions of gems?

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.

How do I install a local gem file?

You can download gems from https://rubygems.org/gems/ or build you local gem via bundle and rack. eg: bundle gem yourGemName. rake install.

Where is my gem file located?

The Gemfile is wherever you want it to be - usually in the main directory of your project and the name of the file is Gemfile . It's convenient to have one because it allows you to use Bundler to manage which gems and which versions of each your project needs to run.


1 Answers

Try, in your Gemfile:

gem "mygem", :path => "/MyPath/MyGem.gem"

Note that it's probably best to use a relative link in there, like:

gem "mygem", :path => "vendor/MyPath/MyGem.gem"
like image 92
Jits Avatar answered Sep 29 '22 14:09

Jits