I had tried in this way:
s.add_dependency 'gem', :path => '../gem'
like add gem in the gemfile,
but it doesn't work, and will cause this error:
/Users/chenqh/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/requirement.rb:81:in `parse': Illformed requirement
It's likely not possible to add local dependencies because other users will not be able to access the gem as it is local dependent and hence of no use after publish. Instead of that, Add remote dependency in your own plugin's gemspec.
Steps -
1) Open gemspec file of your own plugin in vendor/plugins/my_plugin/ and add before the keyword end:
(In this example I have used will_paginate required dependency of my_plugin)
2) Now go in your rails app and edit Gemfile, add:
3) Now in rails app root do:
And dependency of my_plugin (will_paginate in this case) is installed.
Sometimes you want to embed one gem into another gem, nevermind why. You can reference one gempec from another to completely encapsulate a local gem.
EDIT: this appears to only work locally. If you try to install this gemspec from, say, a git repo, it won't know where to get
embedded_gemspec
(even thoughembedded_gemspec
's dependencies come in just fine).While developing 2 gems, gem1 and gem2, requiring that gem1 locally depends on gem2 is quite handy.
You can't do this in your
gemspec
, however, you can do so in your gem'sGemfile
!And then in your gemspec, require your gem like you would normally if that gem was already published:
Just make sure you don't accidentally push that
Gemfile
change!