Very Basic Question

15 views
Skip to first unread message

Rodrigo Botafogo

unread,
Dec 28, 2015, 10:17:31 PM12/28/15
to ruby-bundler

Hello….

Sorry if this a really basic, and even stupid question, but I couldn´t find the proper way of doing this…..

So, I´m developing a Gem, and my users might not have Bundler installed. If I add

require 'bundler/setup'

on a file and my user does not have bundler, then there is a dependency error.

If on the other hand, I do not add

require 'bundler/setup'

then when doing development, the system does not find my dependencies correctly.

How should I configure my bundler so that it allows for people to do: gem install <my_gem>?

Thanks

Andre Arko

unread,
Dec 28, 2015, 10:23:08 PM12/28/15
to ruby-bundler
Hi Rodrigo,

Gems should only need Bundler for development, and never depend on Bundler while they are running. You can use `bundle exec path/to/gem_command` or `bundle exec ruby` to have the gems in your Gemfile available and set up already.

Since this boilerplate is common, when you use `bundle gem` to create a new gem, we set this up for you.

Rodrigo Botafogo

unread,
Dec 29, 2015, 4:11:31 PM12/29/15
to ruby-bundler
Hi Andre,

Thanks.  But if I use bundler for development, then do I need to comment the "require bundler/setup" when publishing the gem? Is there a way of making sure that this command will not end up published and make the Gem crash? 

Rhett Sutphin

unread,
Dec 29, 2015, 5:50:06 PM12/29/15
to ruby-b...@googlegroups.com
Hi Rodrigo,

You should not have “require 'bundler/setup’” in your gem’s code at any time. When you are developing, use `bundle exec` to ensure your tests, etc., have the right gem environment. `bundle exec` modifies the ruby runtime environment so that it’s like you included “require 'bundler/setup’” in your code.

HTH,
Rhett
> --
> 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.

Reply all
Reply to author
Forward
0 new messages