Provides in packages?

Ken Dreyer ktdreyer at ktdreyer.com
Wed Jan 7 05:07:39 UTC 2015


On Tue, Jan 6, 2015 at 9:06 PM, Allen Hewes <allen at decisiv.net> wrote:
>
> I have seen something similar (ruby -Ilib:test -e '...') to this in Fedora
> rubygem- packages. I don't quite understand why this would be done vs testrb
> or even use the gems' supplied method for running its' test suite (e.g. rake
> test).

Yeah, that's one of the bigger head-scratchers about gem packaging.

When I initially started into Ruby and gems packaging, I was under the
impression that Rakefiles were like Makefiles. GNU Make is a small,
simple program with well-understood features, and I figured Rakefiles
would sort of be like Perl's Makefile.PL - extremely standardized
files that pretty much did exactly the same thing from project to
project.

If each gem just implemented a bare-bones Rakefile that only did
"require 'rake/testtask'" or something, that would be the case.
However, most Rakefiles end up being a lot more complicated.

- If a gem author uses Jeweler for packaging, then the Rakefile tries
to load Jeweler, which implies rubygem-jeweler and its depchain have
to be present in the buildroot

- If a gem uses Hoe for packaging, same deal - we have to
BuildRequire: rubygem-hoe

- If a gem has a "rake yard" task, we won't use that in Fedora's
build, but we'd still need to ensure that yard is available in the
buildroot with BuildRequire: rubygem-yard

- If a gem uses Bundler, it's quite likely that the Rakefile will
require "bundler/setup", or "bundler/gem_tasks", etc. and we try very
hard to avoid invoking bundler in Fedora at all.

- Some Rakefiles include other clever things to make the upstream
authors' lives easier, which also happens to pull in other
dependencies, etc.

So the problem is that Fedora is only interested in the "rake test"
task, but in order to even load the Rakefile with the "rake" command,
we have to unconditionally BuildRequire all of that extra stuff.

If a GNU Makefile has a command "make
this-large-thing-with-lots-of-dependencies", but you only want to run
"make test", it's ok if you don't have all the dependencies available
on your system. Make will still let you run the command you want to
run ("make test") without bothering to check whether you've satisfied
every dependency for every possible task it knows about. Sadly
Rakefiles don't work that way.

I think that's why Rakefiles have a reputation in Fedora for being
bloated, and it's why the guidelines recommend against running rake
during the build.

Maybe if upstreams took greater care to catch LoadErrors for gem
dependencies that are truly optional, then this wouldn't be a big
deal. I try to submit patches upstream when things are really
egregious in spec/spec_helper.rb or test/test_helper.rb. But from
upstream's perspective, they often assume the world uses bundler, and
all the gems are available for download via rubygems.org anyway, so
what's the problem :) We've had to meet in the middle between Fedora's
perspective on the world versus the Ruby community's perspective, and
sometimes the results aren't as elegant as I would wish.

To answer your question about why we just run "ruby -e
this-long-and-complicated-copypasta" instead of "testrb", see
https://lists.fedoraproject.org/pipermail/ruby-sig/2014-May/001585.html
. The gems that use rspec do have a much shorter/saner %check section.

- Ken


More information about the ruby-sig mailing list