Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify source in .gemspec file?

I'm building a gem that uses rails-assets-growl gem. This gem can be added to my Gemfile using a different source than 'https://rubygems.org' like this:

source 'https://rails-assets.org' do
  gem 'rails-assets-growl'
end

This works fine in development mode. But, when I publish my gem in rubygems.org growl gem is not included as dependency.

gem dependencies

I think, this is beacuse I need to specify the https://rails-assets.org source in gemspec instead of Gemfile. But, I'm not sure.

So, the question is:

How can I specify a source for a gem in gemspec file?

like image 661
Leantraxxx Avatar asked Jul 18 '16 19:07

Leantraxxx


1 Answers

In order to publish a gem and list the dependencies, you need to use a gem specification, which is different from a Gemfile

In order to list rails-assets-growl as a dependency, you will need to add it to your gem specification. The problem here is that you cannot add a gem with a external location to rubygems, so you will need to first publish rails-assets-growl into rubygems.

If that doesn't work for you, you can still go and create your gem, add a bundler file where you will add the rails-assets-growl and then you will add the gemspec to it, like:

source 'https://rubygems.org'

gemspec

source 'https://rails-assets.org' do
  gem 'rails-assets-growl'
end

the gem won't be listed as a dependency in the last case, but it will be on the gemfile to be used by other people

like image 85
rorra Avatar answered Sep 17 '22 07:09

rorra