# Multipackage Gems

**URL:** <https://www.ruby-forum.com/t/multipackage-gems/97018>\
**Category:** Ruby\
**Created:** [December 9, 2005, 4:00pm UTC](https://www.ruby-forum.com/t/multipackage-gems/97018 "2005-12-09T16:00:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![transfire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c67d28/32.png) [@transfire](https://www.ruby-forum.com/u/transfire)\
**Post date:** [December 9, 2005, 4:00pm UTC](https://www.ruby-forum.com/t/multipackage-gems/97018/1 "2005-12-09T16:00:19Z")

</div>

I have a multipackage project layout:

workspace/  
setup.rb  
packages/  
proj1/  
lib/  
proj2/  
lib/  
…

setup.rb of course was designed to handle this, but how do I create a  
gem that includes all the packages? I have created gems for each  
subproject, and then created a “metagem” that just lists them as  
dependencies, but some endusers aren’t happy with this and want a gem  
that actually _contains_ all the subprojects.

Any suggestions for achieving this? Does Gems have any way to handle  
this itself? If not, would it behove gems to be updated to support  
this?

Thanks,  
T.

---

<div class="post-metadata">

**Author:** ![transfire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c67d28/32.png) [@transfire](https://www.ruby-forum.com/u/transfire)\
**Post date:** [December 9, 2005, 6:22pm UTC](https://www.ruby-forum.com/t/multipackage-gems/97018/2 "2005-12-09T18:22:18Z")

</div>

transfire wrote:

> I have a multipackage project layout:  
> […]  
> [Users] want a gem that actually _contains_ all the subprojects.
> 
> Any suggestions for achieving this? […]

Your gem spec allows you to enumerate the files you want included in the  
gem … what else do you need?

– Jim W.

---

<div class="post-metadata">

**Author:** ![transfire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c67d28/32.png) [@transfire](https://www.ruby-forum.com/u/transfire)\
**Post date:** [December 9, 2005, 7:56pm UTC](https://www.ruby-forum.com/t/multipackage-gems/97018/3 "2005-12-09T19:56:44Z")

</div>

> Your gem spec allows you to enumerate the files you want included in the  
> gem … what else do you need?

Oh yea! 🙂 I was over complicating the situation. Silly me.

Thanks Jim,  
T.

---

<div class="post-metadata">

**Author:** ![transfire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c67d28/32.png) [@transfire](https://www.ruby-forum.com/u/transfire)\
**Post date:** [December 9, 2005, 9:20pm UTC](https://www.ruby-forum.com/t/multipackage-gems/97018/4 "2005-12-09T21:20:41Z")

</div>

Wait a minute! That doesn’t work.

Jim, if I tell it to inlcude ‘packages/ **/lib/** /\*’ then it includes  
them but just like that in the gem. It makes no sense. Wouldn’t one  
then have to use?

require ‘packages/proj1/lib/proj1/file.rb’

Even using require\_paths isn’t helpful b/c I have dozens of  
sub-projects. Considering how Gems works I’m pretty sure that would  
way too inefficent.

Is there are way to tell it how to put them in the gem?

Thanks,  
T.

---

<div class="post-metadata">

**Author:** ![transfire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c67d28/32.png) [@transfire](https://www.ruby-forum.com/u/transfire)\
**Post date:** [December 9, 2005, 11:10pm UTC](https://www.ruby-forum.com/t/multipackage-gems/97018/5 "2005-12-09T23:10:48Z")

</div>

Well, I got it to work using the require\_paths (I assume that’s what  
you meant). But I have my misgivings about it. Correct me if I’m wrong,  
but Gems uses require\_paths and will search every one of the paths for  
a match. Is that right?

So in my case I have (note: I use a YAML file to setup the gemspec) :

```
  require_paths:
  - packages/annotation/lib
  - packages/ansicode/lib
  - packages/association/lib
  - packages/basicobject/lib
  - packages/bbcode/lib
  - packages/binaryreader/lib
  - packages/bitmask/lib
  - packages/classinherit/lib
  - packages/cloneable/lib
  - packages/consoleapp/lib
  - packages/coroutine/lib
  - packages/crypt/lib
  - packages/dictionary/lib
  - packages/enumerablepass/lib
  - packages/expirable/lib
  - packages/floatstring/lib
  - packages/functor/lib
  - packages/heap/lib
  - packages/inheritor/lib
  - packages/interval/lib
  - packages/lisp/lib
  - packages/lrucache/lib
  - packages/mathconstants/lib
  - packages/methodprobe/lib
  - packages/mock/lib
  - packages/multiton/lib
  - packages/nackclass/lib
  - packages/nilcomparable/lib
  - packages/nullclass/lib
  - packages/one/lib
  - packages/openobject/lib
  - packages/paramix/lib
  - packages/pool/lib
  - packages/progressbar/lib
  - packages/reference/lib
  - packages/semaphore/lib
  - packages/stateparser/lib
  - packages/statichash/lib
  - packages/system/lib
  - packages/tagiterator/lib
  - packages/timer/lib
  - packages/tracepoint/lib
  - packages/tuple/lib
  - packages/uninheritable/lib
  - packages/units/lib
  - packages/yamlstruct/lib

```

Thats a lot of places to have to search every time and can’t be very  
efficeint.

But at least it works.

Thanks,  
T.

---

<div class="post-metadata">

**Author:** ![transfire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c67d28/32.png) [@transfire](https://www.ruby-forum.com/u/transfire)\
**Post date:** [December 9, 2005, 9:42pm UTC](https://www.ruby-forum.com/t/multipackage-gems/97018/6 "2005-12-09T21:42:44Z")

</div>

transfire wrote:

> Wait a minute! That doesn’t work.
> 
> Jim, if I tell it to inlcude ‘packages/ **/lib/** /\*’ then it includes  
> them but just like that in the gem. It makes no sense. Wouldn’t one  
> then have to use?
> 
> require ‘packages/proj1/lib/proj1/file.rb’
> 
> Even using require\_paths isn’t helpful b/c I have dozens of  
> sub-projects. Considering how Gems works I’m pretty sure that would  
> way too inefficent.
> 
> Is there are way to tell it how to put them in the gem?

You tell the gem spec where your library directories are (the default is  
just “lib”). RubyGems will make sure they all get added to the load  
path at run time.

– Jim W.

---

<div class="post-metadata">

**Author:** ![transfire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c67d28/32.png) [@transfire](https://www.ruby-forum.com/u/transfire)\
**Post date:** [December 10, 2005, 12:48am UTC](https://www.ruby-forum.com/t/multipackage-gems/97018/7 "2005-12-10T00:48:59Z")

</div>

On 09/12/05, Trans [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> way too inefficent.
> 
> Is there are way to tell it how to put them in the gem?

No, but there should be. If you look at my Rakefile for PDF::Writer  
(especially, but I think most of them), I do a bit of transformation  
on the filenames when I package into .tar.gz. I would _love_ to see  
the same capabilities added to RubyGems so that I can tell it not only  
where to FIND the source files but where to PLACE them in the internal  
tarfile. It’s not that difficult.

-austin
