I am creating a gem, which has a dependency on another published gem.
In my_gem.gemspec, I have added the dependency to the other gem:
gem.add_dependency "other_gem", "~> 1.0.0"
Now, I found a feature that can be tweaked in other_gem, so I forked the repository, made my changes and committed it to the fork (It has not been pulled into the original repository).
My question is how do I tell my_gem to lookup other_gem locally? The below code snippet is not valid, as :path
is not an option in add_dependency
call, as mentioned in Gem Specification Reference:
gem.add_dependency "other_gem", "~> 1.0.0", :path => '/path/to/local/other_gem
Locally it's much easier: while you're doing development, you can include:
gem "other_gem", :path => '/path/to/local/other_gem'
or
gem "other_gem", :git => "git@github.com:/your_github/other_gem.git"
in your gemfile, as this should override the gemspec
Locally it is not likely possible to give path to the gem dependency because if you are doing so that means you are imposing a restriction to the self made gem that it is depending locally to any other gem.
This is not desirable as when you will upload it, this will not work. So the solution is to add remote dependency in your own plugin's gemspec.
See my SO post for the same here.
I would create and install a new other_gem
-version, e.g. '1.0.0.Subash_fix' and use it as
gem.add_dependency "other_gem", "= 1.0.0.Subash_fix"
When there is a new official version of the gem with your patch you switch back to the official one:
gem.add_dependency "other_gem", "~> 1.0.1"