JZ.
JZ.

Reputation: 21877

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

Upvotes: 9

Views: 9932

Answers (3)

Jits
Jits

Reputation: 9728

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"

Upvotes: 23

Devin M
Devin M

Reputation: 9752

You can do this using gem 'gemname', :path => "/your/path/here" It is very useful when you are building local gems for development or if you have your own fork of a gem locally.

Upvotes: 7

Bishma Stornelli
Bishma Stornelli

Reputation: 2569

I did it like Jits said but It didn't work. It seems that rails expect a folder path instead of a .gem path.

It worked for me

gem "mygem", :path => "vendor/gems/mygemfolder/"

If it works for you but you can't deploy to heroku (like it happened to me) you need to specify the version of the gem:

gem 'mygem', '= x.x.x', :path => 'vendor/gems/mygemfolder/'

Upvotes: 3

Related Questions