New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Inline] Add bundler/inline to allow using Bundler without a Gemfile #3440

Merged
merged 5 commits into from Mar 19, 2015

Conversation

Projects
None yet
7 participants
@segiddins
Member

segiddins commented Feb 27, 2015

Closes bundler/bundler-features#47.

Enables scripts such as the following to work on their own, as long as bundler is installed:

#!/usr/bin/env ruby

require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'
  gem 'json'
  gem 'nap', require: 'rest'
  gem 'cocoapods', '> 0.pre'
end

puts Pod::VERSION
@segiddins

This comment has been minimized.

Show comment
Hide comment
@segiddins

segiddins Mar 19, 2015

Member

Those 2 spec failures look like API timeouts to me.

Member

segiddins commented Mar 19, 2015

Those 2 spec failures look like API timeouts to me.

@TimMoore

This comment has been minimized.

Show comment
Hide comment
@TimMoore

TimMoore Mar 19, 2015

Member

I restarted the failing jobs.

Member

TimMoore commented Mar 19, 2015

I restarted the failing jobs.

@indirect

This comment has been minimized.

Show comment
Hide comment
@indirect

indirect Mar 19, 2015

Member

Er, just to double-check, in the example script, you would still have to require 'cocoapods', right?

Member

indirect commented Mar 19, 2015

Er, just to double-check, in the example script, you would still have to require 'cocoapods', right?

@segiddins

This comment has been minimized.

Show comment
Hide comment
@segiddins

segiddins Mar 19, 2015

Member

@indirect right now, using bundler/inline's gemfile method will also call require on the environment, just as if you'd somehow done a require 'bundler/require' afterwards.

Member

segiddins commented Mar 19, 2015

@indirect right now, using bundler/inline's gemfile method will also call require on the environment, just as if you'd somehow done a require 'bundler/require' afterwards.

@indirect

This comment has been minimized.

Show comment
Hide comment
@indirect

indirect Mar 19, 2015

Member

There is no bundler/require, though. :) There's a bundler/setup, but that means you still need to explicitly call require.

Member

indirect commented Mar 19, 2015

There is no bundler/require, though. :) There's a bundler/setup, but that means you still need to explicitly call require.

@segiddins

This comment has been minimized.

Show comment
Hide comment
@segiddins

segiddins Mar 19, 2015

Member

Ah my bad. It'd be like calling require 'bundler/setup'; Bundler.require

Member

segiddins commented Mar 19, 2015

Ah my bad. It'd be like calling require 'bundler/setup'; Bundler.require

@indirect

This comment has been minimized.

Show comment
Hide comment
@indirect

indirect Mar 19, 2015

Member

In order to encourage reasonable growth of a script into a multi-file project, can we leave out the Bundler.require part? Requiring the world up front is an anti-pattern that I wish Rails didn't encourage. :'(

Member

indirect commented Mar 19, 2015

In order to encourage reasonable growth of a script into a multi-file project, can we leave out the Bundler.require part? Requiring the world up front is an anti-pattern that I wish Rails didn't encourage. :'(

@segiddins

This comment has been minimized.

Show comment
Hide comment
@segiddins

segiddins Mar 19, 2015

Member

André and I just agreed that not auto-requiring in this circumstance would make users do a redundant gem 'foo' && require 'foo' for every gem that they include in the inline gemfile, which is probably worse than (slightly) encouraging en-mass requiring.

Member

segiddins commented Mar 19, 2015

André and I just agreed that not auto-requiring in this circumstance would make users do a redundant gem 'foo' && require 'foo' for every gem that they include in the inline gemfile, which is probably worse than (slightly) encouraging en-mass requiring.

@indirect

This comment has been minimized.

Show comment
Hide comment
@indirect

indirect Mar 19, 2015

Member

Can you document this somewhere, preferably with examples? :D (Maybe even on the Bundler website?!)

Member

indirect commented Mar 19, 2015

Can you document this somewhere, preferably with examples? :D (Maybe even on the Bundler website?!)

@andremedeiros

This comment has been minimized.

Show comment
Hide comment
@andremedeiros

andremedeiros Mar 19, 2015

Member

This is really nice! 👍

Member

andremedeiros commented Mar 19, 2015

This is really nice! 👍

indirect added a commit that referenced this pull request Mar 19, 2015

Merge pull request #3440 from segiddins/seg-inline
[Inline] Add bundler/inline to allow using Bundler without a Gemfile

@indirect indirect merged commit ea168ea into bundler:master Mar 19, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@segiddins segiddins deleted the segiddins:seg-inline branch Mar 19, 2015

@cstrahan

This comment has been minimized.

Show comment
Hide comment
@cstrahan

cstrahan Mar 20, 2015

@segiddins Excellent! This new feature should greatly simplify the way we do Ruby packaging in NixOS. Thanks!

cstrahan commented Mar 20, 2015

@segiddins Excellent! This new feature should greatly simplify the way we do Ruby packaging in NixOS. Thanks!

@schneems

This comment has been minimized.

Show comment
Hide comment
@schneems

schneems May 7, 2015

Contributor

Requiring the world up front is an anti-pattern

Do you have more thoughts on this written down somewhere? I would think we want to preload to take advantage of CoW with forking webservers.

Contributor

schneems commented May 7, 2015

Requiring the world up front is an anti-pattern

Do you have more thoughts on this written down somewhere? I would think we want to preload to take advantage of CoW with forking webservers.

@cstrahan

This comment has been minimized.

Show comment
Hide comment
@cstrahan

cstrahan May 7, 2015

@schneems I believe the anti-pattern that @indirect is referring to is the fact that - assuming you don't require what you use - your tests (as just one example) can't be run without requiring everything up front. So while the act of requiring everything up front is great (with respect to CoW), you should still require what you need where you need it.

cstrahan commented May 7, 2015

@schneems I believe the anti-pattern that @indirect is referring to is the fact that - assuming you don't require what you use - your tests (as just one example) can't be run without requiring everything up front. So while the act of requiring everything up front is great (with respect to CoW), you should still require what you need where you need it.

@segiddins

This comment has been minimized.

Show comment
Hide comment
@segiddins

segiddins May 7, 2015

Member

This is not really a relevant discussion for this particular feature, which is targeted at single-file scripts.

Member

segiddins commented May 7, 2015

This is not really a relevant discussion for this particular feature, which is targeted at single-file scripts.

@schneems

This comment has been minimized.

Show comment
Hide comment
@schneems

schneems May 7, 2015

Contributor

Thank you @cstrahan, makes sense. Thanks for the feature @segiddins i cede this thread back to you.

Contributor

schneems commented May 7, 2015

Thank you @cstrahan, makes sense. Thanks for the feature @segiddins i cede this thread back to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment