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 '' like this:

source '' do
  gem 'rails-assets-growl'

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

gem dependencies

I think, this is beacuse I need to specify the 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?

Show source
| ruby   | rubygems   | gemfile   | gemspecs   2016-07-18 21:07 1 Answers

Answers to How to specify source in .gemspec file? ( 1 )

  1. 2016-07-18 22:07

    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 ''
    source '' do
      gem 'rails-assets-growl'

    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

Leave a reply to - How to specify source in .gemspec file?

◀ Go back