dependency madness!

2 views
Skip to first unread message

rhubarb

unread,
Mar 30, 2009, 2:46:14 PM3/30/09
to New Gem Generator
When creating a new project with newgem, the newgem gem becomes a
dependency automatically (in Rakefile).

Thing is, when I got to test my newly created gem (rake gem) on a
different machine, I see I need to install newgem because it's a
dependency. Naturally, no prob there.

But then I go to do it (installing it independently here because I was
doing a local install of my gem) and there are a LOT of dependencies.
A *lot*. I mean, like too many.
Just look at the list below (some of them are depended on twice then
install twice - bizarre).
Now I like newgem and I'm prepared to install all this guff to get it
to work.
But I don't want users of my little gem to have to make the same
commitment.
I mean, my gem depends on about 2 or 3 other public gems and that's
about enough.

How can I reduce the dependency list?
Is it like this because newgem is needed for the installer?
could I just depend on hoe or something else?
thanks
rhubarb


---- dependencies of newgem ----

[c:\]gem install newgem
Bulk updating Gem source index for: http://gems.rubyforge.org
Install required dependency rubigen? [Yn] y
Install required dependency activesupport? [Yn] y
Install required dependency hoe? [Yn] y
Install required dependency rubyforge? [Yn] y
Install required dependency rake? [Yn] y
Install required dependency hoe? [Yn] y
Install required dependency RedCloth? [Yn] y
Select which gem to install for your platform (i386-mswin32)
1. RedCloth 4.1.9 (universal-java)
2. RedCloth 4.1.9 (x86-mswin32-60)
3. RedCloth 4.1.9 (ruby)
4. RedCloth 4.1.1 (x86-mswin32-60)
5. RedCloth 4.1.1 (universal-java)
6. RedCloth 4.1.1 (ruby)
7. Skip this gem
8. Cancel installation
> 2
Install required dependency cucumber? [Yn] y
Install required dependency term-ansicolor? [Yn] y
Install required dependency treetop? [Yn] y
Install required dependency polyglot? [Yn] y
Install required dependency polyglot? [Yn] y
Install required dependency diff-lcs? [Yn] y
Install required dependency builder? [Yn] y
Install required dependency hoe? [Yn] y

rhubarb

unread,
Apr 2, 2009, 1:40:14 PM4/2/09
to New Gem Generator
This is the second time lately that I raise what seems like a obvious
issue and end up answering myself. There's not enough traffic on this
group. Has newgem lapsed into disuse (shame)

Anyway, here's what I've found so far:
If I create a gem spec with 'rake gemspec' I see this code for
dependencies

if s.respond_to? :specification_version then
current_version =
Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 2

if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new
('1.2.0') then
s.add_runtime_dependency(%q<hpricot>, [">= 0.6"])
s.add_runtime_dependency(%q<mechanize>, [">= 0.7.5"])
s.add_runtime_dependency(%q<builder>, [">= 2.1.2"])
s.add_runtime_dependency(%q<fastercsv>, [">= 1.2.3"])
s.add_development_dependency(%q<newgem>, [">= 1.3.0"])
s.add_development_dependency(%q<hoe>, [">= 1.8.0"])
else
s.add_dependency(%q<hpricot>, [">= 0.6"])
s.add_dependency(%q<mechanize>, [">= 0.7.5"])
s.add_dependency(%q<builder>, [">= 2.1.2"])
s.add_dependency(%q<fastercsv>, [">= 1.2.3"])
s.add_dependency(%q<newgem>, [">= 1.3.0"])
s.add_dependency(%q<hoe>, [">= 1.8.0"])
end
else
s.add_dependency(%q<hpricot>, [">= 0.6"])
s.add_dependency(%q<mechanize>, [">= 0.7.5"])
s.add_dependency(%q<builder>, [">= 2.1.2"])
s.add_dependency(%q<fastercsv>, [">= 1.2.3"])
s.add_dependency(%q<newgem>, [">= 1.3.0"])
s.add_dependency(%q<hoe>, [">= 1.8.0"])
end

So you see if the local version of rubygem is recent enough (1.2+) it
can distinguish between development and runtime dependencies. Hoe and
NewGem are development dependencies but I don't want them to be
runtime dependencies.
Unfortunately this code above means that on the end-user's system if
their rubygem is pre-1.2, they'll get all of the development deps as
runtime deps.
I think this is pretty dumb of rubygem (I traced the code that does
this to the specification.rb in the rubygem gem - so it's not newgen
or hoe to blame this time) - it seems obvious to me that if I the
developer am smart enough to specify _development_ dependencies, then
a) I don't want my end users dealing with them and b) I already have
the latest rubygem installed. So the else clauses should filter out
the development deps.

So I'd like to take newgem and hoe out altogether. I can take out
newgem but hoe adds itself.
I see Dr Nic replying on some forum that newgem removes the hoe
behaviour of adding itself - but it doesnt seem to - perhaps I
misread.
Any ideas? I'm getting ready to do one of the following
1. create gemspecs edit them and create the gem itself (any help with
this, e.g. will commands like 'rake release' pick up my hand-crafted
gem or recreate the gem with the evil dependences?)
2. hack hoe or newgem to try and stop the madness
3. give into the madness and start again with Dr Bones (don't want to
go there yet because I like the website stuff that Dr Nic provides)

ideas?

rhubarb

unread,
Apr 2, 2009, 2:00:01 PM4/2/09
to New Gem Generator
So I hacked newgem's hoe_patched.rb file to remove the line that adds
hoe as a dependency to everything.

When I went to install on my old-gem-version machine again, I had to
install mechanize (one of my real dependencies) separately (dunno why
- perhaps because I'm installing my gem -l?).
Anyway - there it is again - mechanize needs to install hoe! and
rubyforge! and hoe again!

argh!

hoe is beginning to look like a virus.
Just about every gem out there created with hoe or (by association)
with newgem is going to have, by default, this behaviour on user
machines with old newgem versions of always installing everything.

In a way not entirely hoe's fault since as I said before I think
rubygem spec should generate the spec without dev-deps on older
version. But knowing that it doesn't, hoe should avoid adding itself
as a dep at all (yes even a dev-dep) and stop spreading itself around
like a virus.

thats my 2c
Reply all
Reply to author
Forward
0 new messages