Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

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

Merged
merged 5 commits into from
Mar 19, 2015

Conversation

segiddins
Copy link
Member

Closes rubygems/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
Copy link
Member Author

Those 2 spec failures look like API timeouts to me.

@TimMoore
Copy link
Contributor

I restarted the failing jobs.

@indirect
Copy link
Member

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

@segiddins
Copy link
Member Author

@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
Copy link
Member

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

@segiddins
Copy link
Member Author

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

@indirect
Copy link
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. :'(

@segiddins
Copy link
Member Author

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
Copy link
Member

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

@andremedeiros
Copy link
Member

This is really nice! 👍

indirect added a commit that referenced this pull request Mar 19, 2015
[Inline] Add bundler/inline to allow using Bundler without a Gemfile
@indirect indirect merged commit ea168ea into rubygems:master Mar 19, 2015
@segiddins segiddins deleted the seg-inline branch March 19, 2015 19:03
@cstrahan
Copy link

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

@schneems
Copy link
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
Copy link

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
Copy link
Member Author

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

@schneems
Copy link
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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Gemfile-free dependency specification
7 participants