Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Local Dependency in Gem .gemspec

Tags:

I am working on a gem (Gem A) which uses another gem (Gem B) that I have also written. Until this point Gem B has been added in the gemspec for Gem A:

gem.add_dependency "gem_a", "~> 0.0.4" 

But I now find the need to debug using my local version.

To declare a local dependency in a Gemfile I could do:

gem 'gem_a', path: "/local/path/to/gem_a" 

But how do I declare a local dependency in a .gemspec?

like image 456
Undistraction Avatar asked Sep 07 '13 19:09

Undistraction


People also ask

What is a Gemfile?

A Gemfile is a file that is created to describe the gem dependencies required to run a Ruby program. A Gemfile should always be placed in the root of the project directory.

What are dependencies Ruby?

A "dependency" in the general sense of the word means that a table is being used by another table - thus one table "depends" on another.


1 Answers

Just so folks can find the answer (slightly) faster...

If you're creating a gem, and need to add a local dependency (while developing), in your gem's Gemfile, do something like:

source 'https://rubygems.org'  # Specify your gem's dependencies in mygem.gemspec gemspec  gem "local_gem", path: "/path/to/local_gem" 

When you bundle you should see it's now using the local path

Using local_gem 0.1.0 from source at `/path/to/local_gem` 
like image 76
tehprofessor Avatar answered Oct 02 '22 20:10

tehprofessor