"Local" group or group metadata for optional gems

62 views
Skip to first unread message

Lucas Húngaro

unread,
May 17, 2011, 11:45:10 PM5/17/11
to ruby-bundler
Hi there!

It's a common issue to have gems that one developer uses while working
on some app, but other developers in the team don't want to use.
Things like wirble, looksee and awesome_print comes to mind. It's the
kind of thing you don't want to force other people to install since
it's not an application dependency, it's just a non-required
environment tool. So, putting those dependencies in the Gemfile is bad
but also required, as there's no way to use them otherwise (at least I
haven't see one yet).

To solve this I thought of two options:

1. "Local" gems group, like:
group :local do
gem "wirble"
gem "looksee"
end

2. Adding some metadata option to flag an optional gem:
group :development, :optional => true do
gem "wirble"
gem "looksee"
end

Bundler then wouldn't complain if these gems aren't installed and they
would be installed only if a flag is provided, like:

$ bundler install --include-optional

Is this a good option?

Christopher Small

unread,
May 18, 2011, 3:14:35 PM5/18/11
to ruby-b...@googlegroups.com
Seems like ideally you would want to have something more robust to allow for multiple optional groups. That way, if some of the devs want to use gem A but not gem B and other developers want to use gem B but not gem A, that could be accomplished with optional A and a B groups. Maybe "group" is not the right name for these things, given that it already has meaning. Maybe "set" or something.

Chris




--
You received this message because you are subscribed to the Google Groups "ruby-bundler" group.
To post to this group, send email to ruby-b...@googlegroups.com.
To unsubscribe from this group, send email to ruby-bundler...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ruby-bundler?hl=en.


Lucas Húngaro

unread,
May 18, 2011, 4:23:29 PM5/18/11
to ruby-bundler
Hmmm, maybe add an "optional" flag to each gem, so we don't mess with
groups:

group :development do
gem "wirble", :optional => true
gem "looksee", :optional => true
gem "rspec-rails"
end


On May 18, 4:14 pm, Christopher Small <metasoar...@gmail.com> wrote:
> Seems like ideally you would want to have something more robust to allow for
> multiple optional groups. That way, if some of the devs want to use gem A
> but not gem B and other developers want to use gem B but not gem A, that
> could be accomplished with optional A and a B groups. Maybe "group" is not
> the right name for these things, given that it already has meaning. Maybe
> "set" or something.
>
> Chris
>

Christopher Small

unread,
May 18, 2011, 4:55:58 PM5/18/11
to ruby-b...@googlegroups.com
What about something like

   group :development do
     gem "wirble", :optional => true, :set => "A"
     gem "looksee", :optional => true, :set => "B"
     gem "rspec-rails"
   end

so that you could do

   bundle install --include-optional=B

if you just wanted those in set B, but not in set A?

Chris

Lucas Húngaro

unread,
May 18, 2011, 9:25:08 PM5/18/11
to ruby-bundler
That would be nice too.

On May 18, 5:55 pm, Christopher Small <metasoar...@gmail.com> wrote:
> What about something like
>
>    group :development do
>      gem "wirble", :optional => true, :set => "A"
>      gem "looksee", :optional => true, :set => "B"
>      gem "rspec-rails"
>    end
>
> so that you could do
>
>    bundle install --include-optional=B
>
> if you just wanted those in set B, but not in set A?
>
> Chris
>

Alex Chaffee

unread,
May 18, 2011, 10:06:25 PM5/18/11
to ruby-b...@googlegroups.com
Bundler can already do this, almost. 

   group :extra do

     gem "wirble"
     gem "looksee"
   end

Fun developers would do "bundle install"

Boring developers would do "bundle install --without extra"

The only wrinkle is that you're asking for a group that's excluded by default, rather than all groups being included by default. Which sounds potentially useful but also potentially complicated.

So, putting those dependencies in the Gemfile is bad
> but also required, as there's no way to use them otherwise (at least I
> haven't see one yet).

If using rvm, you can put them in the "global" gemset (rvm create global; rvm use @global; gem install wirble; rvm use @)

Lucas Húngaro

unread,
May 19, 2011, 10:49:28 AM5/19/11
to ruby-bundler
I tried to use global gemsets to no avail (with Rails). When I fire up
the app console, these "local" gems (no present in the Gemfile) aren't
loaded.

On May 18, 11:06 pm, Alex Chaffee <a...@stinky.com> wrote:
> Bundler can already do this, almost.
>
>    group :extra do
>      gem "wirble"
>      gem "looksee"
>    end
>
> Fun developers would do "bundle install"
>
> Boring developers would do "bundle install --without extra"
>
> The only wrinkle is that you're asking for a group that's excluded by
> default, rather than all groups being included by default. Which sounds
> potentially useful but also potentially complicated.
>
> > So, putting those dependencies in the Gemfile is bad
> > but also required, as there's no way to use them otherwise (at least I
> > haven't see one yet).
>
> If using rvm, you can put them in the "global" gemset (rvm create global;
> rvm use @global; gem install wirble; rvm use @)
>
> --
> Alex Chaffee - a...@stinky.com -http://alexch.github.com
Reply all
Reply to author
Forward
0 new messages