Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How am I supposed to use bundle install --standalone with a Rails app?

bundle install --standalone seems like a wonderful idea, but I'm having a hard time wrapping my head around how to use it that doesn't wind up requiring you to have rubygems or bundler installed.

It generates a bundler/setup.rb which adds the lib and ext directories of my gems, seemingly in order. Presumably, all I'd need to do is add it to the load path, and all's well.

But bundler/setup.rb doesn't seem to actually require anything.

Now, that's fine, because the normal bundler/setup doesn't require anything either and leaves it to the app to call Bundler.require

Rails by default does the requiring with this little ditty:

if defined?(Bundler)
  Bundler.require(*Rails.groups(:assets => %w(development test)))
end

At the point it hits this, Bundler isn't defined (bundler/setup.rb doesn't define it), so it skips over the block.

So how exactly do I require bundler. If bundle install --standalone actually bundled bundler, presumably, I could manually call require bundler and then have Bundler defined, but it seems to exclude itself from the bundle.

Is there an app out there that actually uses bundle install --standalone, and if so, how?

like image 218
Steven Avatar asked Dec 19 '11 23:12

Steven


1 Answers

To get this to work with Rails, you remove the Bundler.require call and manually add all of the require lines where they're needed.

This has pros and cons. On the plus side, it can make loading your app faster as not all the gems have to be required at load time. It also makes clear what gems are being used where.

On the down side, you have to add all the require calls to your application.

Take a look at Myron Marstons blog post for a better explanation.

like image 159
dj2 Avatar answered Sep 19 '22 14:09

dj2