Generate static groups for Bundle.require when creating a standalone bundle. #1597

Closed
wants to merge 1 commit into
from

Projects

None yet

6 participants

@cowboyd
Contributor
cowboyd commented Dec 21, 2011

For every group we create a file that requires all of the code for its gems.
So, for example if you have the following Gemfile:

gem "abc"

group :foo do
  gem "xyz"
  gem "zzz"
end

The standalone will generate

bundler/setup/default.rb
bundler/setup/foo.rb

so that when you call Bundler.require(:default, :foo), it will load
those files which contain a listing of requires for that group.

As I see it, there is still some work to be done in standalone because all dependency information is lost at runtime, but that's a separate bit of work.

@wycats
Contributor
wycats commented Dec 22, 2011

The idea behind standalone mode is to create a bundle that is standard Ruby and does not have a dependency on the bundler library.

In the 0.8 era of Bundler, we tried to emulate the Bundler library when in standalone mode in a similar way to what you are doing here. People continued to ask for more features that were like the full bundler library, and the standalone version of the runtime (a) became large, and (b) was often out of sync with the normal runtime.

For me, the point of standalone is to create a prepackaged, deployable version of the bundle. If you have dynamic needs (runtime determination of groups), you should be using the normal library.

If you want to specify specific groups, you can do bundle install --standalone group1 group2

@cowboyd
Contributor
cowboyd commented Dec 22, 2011

On Dec 21, 2011, at 9:53 PM, Yehuda Katz wrote:

The idea behind standalone mode is to create a bundle that is standard Ruby and does not have a dependency on the bundler library.

To run without a dependency on bundler or rubygems is precisely my use case. Specifically, I'm trying to convert several rails application to use standalone.

In the 0.8 era of Bundler, we tried to emulate the Bundler library when in standalone mode in a similar way to what you are doing here. People continued to ask for more features that were like the full bundler library, and the standalone version of the runtime (a) became large, and (b) was often out of sync with the normal runtime.

For me, the point of standalone is to create a prepackaged, deployable version of the bundle. If you have dynamic needs (runtime determination of groups), you should be using the normal library.

I don't have any particular need for dynamicity; The only advantage for it is that we can deploy the same bundle we test against on our CI server. In any case, it seems to me that even with all groups preselected
at bundle-time there should be a mechanism to require the libs they contain in dependency order a-la Bundler.require().

We could move that code in to the standalone setup.rb, but I reckon there's value in letting the developer decide when to setup the load path, and when (and if) to actually do a full require. What would you suggest?

If you want to specify specific groups, you can do bundle install --standalone group1 group2


Reply to this email directly or view it on GitHub:
#1597 (comment)

@wycats
Contributor
wycats commented Dec 22, 2011

I would be ok with adding a bundler/require.rb that required the dependencies for groups selected at bundle-time. Thoughts?

@cowboyd
Contributor
cowboyd commented Dec 23, 2011

I think that sounds great. I'll go ahead make the changes sometime next week. Cheers!

On Dec 22, 2011, at 17:41, Yehuda Katzreply@reply.github.com wrote:

I would be ok with adding a bundler/require.rb that required the dependencies for groups selected at bundle-time. Thoughts?


Reply to this email directly or view it on GitHub:
#1597 (comment)

@cowboyd cowboyd Generate static requires when creating a standalone bundle.
Creates a manifest at 'bundler/require.rb' that contains 
all of the files needed to be required by the gems in a 
standalone bundle. 

Once the standalone bundle is in your load path, it can
be required with:

    require 'bundler/require'
7d645c3
@cowboyd
Contributor
cowboyd commented Jan 4, 2012

Alrighty. Here's an implemention of bundler/require.rb as discussed.

@travisbot

This pull request fails (merged 7d645c3 into 7f7f7c0).

@troelskn

What happened to this patch? It seems like a useful addition to me.

@indirect
Member

Require isn't a feature that we want to add to standalone -- the idea of standalone is that it removes Bundler and Rubygems from the runtime application, so you should use straight ruby requires to pull in your code. Adding require to standalone sends is down the dangerous path of reimplementing Bundler as a separate file that gets copied into your standalone Bundle. That ended so badly for Bundler 0.9 that I'm very cautious of anything that might do that again :P

On Mar 21, 2013, at 12:44 AM, Troels Knak-Nielsen notifications@github.com wrote:

What happened to this patch? It seems like a useful addition to me.


Reply to this email directly or view it on GitHub.

@troelskn

OK - I can see the reasoning behind that.

@jaggederest

Is this still alive? I think it can probably be closed, from reading the discussion.

@indirect indirect closed this Aug 4, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment