Gem Dependencies

14 views
Skip to first unread message

Arco

unread,
Oct 13, 2010, 4:10:39 AM10/13/10
to jeweler.rb
in 1.5.0.pre4, it looks like you've got to specify Gem dependencies in
both the Gemfile and the Rakefile.

Is that right? Is there any way to specify the Gem dependencies just
once ??

Josh Nichols

unread,
Oct 13, 2010, 8:29:08 AM10/13/10
to jewel...@googlegroups.com
Definitely a bug as you suspect.

Will check it out, but if you can confirm against pre5, that'd help too. Also, if you could point me at the repository of the gem having the problem, that'd help me validate it too.

One thought that occurred to me is that the bundler support changed a bit from a much earlier period, so if you had generated the project from then, there might be a problem. Specifically, runtime dependencies are no longer in the `group :runtime` in Gemfile, ie your Gemfile should look like:

# GOOD!
gem "activesupport", ">= 2.3.5"
# NOOOO!
group :runtime do
  gem "activesupport", ">= 2.3.5"
end

- Josh

Arco

unread,
Oct 13, 2010, 11:31:30 AM10/13/10
to jeweler.rb
OK I checked out 1.5.0.pre5. It looks like pre5 works like pre4 - you
have to specify gem dependencies twice - once in the Gemfile, and
again in the Rakefile.

Ideally you would only specify gem dependencies once...

Here's some doc on Bundler's 'gemspec' statement, which might be
helpful. With this, Bundler could grab all the dependency definitions
from the .gemspec.

http://gembundler.com/rubygems.html

- Andy

Josh Nichols

unread,
Oct 13, 2010, 1:20:25 PM10/13/10
to jewel...@googlegroups.com
Just to make it clear, yes, gem dependencies should only be specified once :)

There is logic in place in lib/jewer/specification.rb to introspect into the Gemfile and load dependencies from that. This is basically the same way the old gemspec.add_bundler_dependencies worked before they deprecated it.

`gemspec` has some interesting consequences for jeweler. It looks at the gemspec on the filesystem, and works from that. However, in most cases, jeweler is managing the most recent gemspec, so it might be out of sync with what's on the filesystem. Fortunately, building the gem will handle regenerating the gemspec.

Given that, I think for people using jeweler, that should work alright, but because jeweler uses jeweler, that might be a problem. Basically, you wouldn't be able to develop jeweler without a copy of jeweler installed, which makes for some fun bootstrapping problems. It may just be that jeweler needs some of its own hacks to do this, and users of jeweler can just use `gemspec` in Gemfile.

Did you see my notes about having only the dependencies in the Gemfile? If you have that, make sure to have regular dependencies in the default group (ie no group), and jeweler should handle populating the gemspec from those. If that isn't working, and you can push your code somewhere, that'd definitely help me track down the issue further.

- Josh

Arco

unread,
Oct 14, 2010, 12:10:26 PM10/14/10
to jeweler.rb
OK I did a bit more playing around and discovered that everything
works as I had expected:
- you just need to specify dependencies in the Gemfile
- the generated gemspec contains references extracted from the Gemfile

I was confused because after I generated the gem with Jeweler, I saw
duplicate entries for the 'development' gems in both the Rakefile and
the Gemfile.

Thanks again!

Andy

Josh Nichols

unread,
Oct 14, 2010, 12:45:06 PM10/14/10
to jewel...@googlegroups.com
Great, thanks for digging in!

If that's the case, I think it's a bug in the generator, where it adds the dependencies to both. It's possible that this was just a bug at the point you generated, but it should be easy to confirm if it's still a problem :)

- Josh

Arco

unread,
Oct 15, 2010, 6:55:54 AM10/15/10
to jeweler.rb
I tried a couple of other things:
- if you remove all the gem references from the Rakefile, 'rake
gemspec' works fine
- if have duplicate gem references in the Rakefile and the Gemfile,
both references are included in the gemspec

So yeah - it would be better if the generator didn't put the gem
dependency references into the Rakefile.

- Andy

Josh Nichols

unread,
Oct 18, 2010, 11:51:46 PM10/18/10
to jewel...@googlegroups.com
Basically what I was trying to get out is that'd a patch fixing said problem would be greatly appreciated :) Otherwise, I'll get to it the next time I sit down for jeweler time, but it probably will be later this week.
Reply all
Reply to author
Forward
0 new messages