Best practice for grouping non-essential Gems

18 views
Skip to first unread message

Paul Menzel

unread,
Jan 30, 2016, 2:35:15 PM1/30/16
to ruby-b...@googlegroups.com
Dear Bundler folks,


if you have a free software project and add monitoring Gems to it, not
everybody is going to use the same monitoring service. In our case it’s
New Relic, so the Gem *newrelic_rpm* should be added to make our lives
easier.

Not to force anybody else to install, it was thought to make it a group
[1].

```
gem 'newrelic_rpm', group: :new_relic
```

This way, people not using New Relic, can easily avoid installing it,
running `bundle --without new_relic`.

Now I was surprised, that Ruby on Rails did not load it and I am
hesitant to change `Bundler.require` for any newly added group.

So, I am stuck here. Could you please show me a feasible, maintainable
solution? That’d be awesome!


Thanks,

Paul


[1] http://bundler.io/groups.html
--
GPG-Schlüssel: 33623E9B
Fingerabdruck = 0EB1 649D 4361 D04F 3C70 6F71 4DD7 BF75 3362 3E9B

Giant Monkey Software Engineering GmbH

Brunnenstr. 7D
10119 Berlin Mitte

Geschäftsführer Adrian Fuhrmann, Lion Vollnhals und Paul Menzel

USt-IdNr.: DE281524720
HRB 139495 B Amtsgericht Charlottenburg
signature.asc

André Arko

unread,
Jan 30, 2016, 2:37:28 PM1/30/16
to ruby-b...@googlegroups.com
Rails’ call to Bundler.require isn’t the only way to load gems. You can use require, too:

begin
require ‘newrelic_rpm’
rescue LoadError
end
> --
> You received this message because you are subscribed to the Google Groups "ruby-bundler" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ruby-bundler...@googlegroups.com.
> To post to this group, send email to ruby-b...@googlegroups.com.
> Visit this group at https://groups.google.com/group/ruby-bundler.
> For more options, visit https://groups.google.com/d/optout.

Paul Menzel

unread,
Feb 2, 2016, 2:30:36 AM2/2/16
to ruby-b...@googlegroups.com
Dear André,


Am Samstag, den 30.01.2016, 11:37 -0800 schrieb André Arko:
> Rails’ call to Bundler.require isn’t the only way to load gems. You
> can use require, too:
>
> begin
> require ‘newrelic_rpm’
> rescue LoadError
> end

Interesting! Thank you for the suggestion.

I am still searching for a way, where this would happen right out of the
box, so that only one place, in this case `Gemfile`, has to be adapted.
Otherwise this would be too much hassle to add all the Gems and it might
be better, if each user adds the desired Gems itself. That would be
extra maintenance stuff.


Thanks,

Paul
signature.asc
Reply all
Reply to author
Forward
0 new messages