carlhuda/bundler — Issue #1603: Specifying a Gemfile within the application?
Author: jaylevitt
Created: 2011-12-30 16:28:43+00:00
State: open

I'm writing a set of ruby scripts that will live in people's `/usr/local/bin` directory. Rather than have them manually install gem dependencies, Bundler seems a great way to keep the dependencies and source together.

But: Is there a "proper" way for an application to say "This is the path to my Gemfile"? Right now, it appears not; I can either sacrifice usability, and do:

cd project1
ls -1 Gemfile #=> Gemfile
./do_something

or I can sacrifice what I assume is my soul and reputation, and do:

which do_something #=> /usr/local/bin/do_something
do_something

where do_something is:

#!/usr/bin/env ruby
ENV['BUNDLE_GEMFILE'] = /usr/local/lib/Gemfiles/do_something/Gemfile
require 'rubygems'
require 'bundler'
Bundler.require(:default)

Is there a better way, perhaps in bundler 1.1? I suspect this hasn't been a big use case so far, since Rails is the biggest use case for Bundler, but as Bundler grows to replace many rubygems use cases, this is one of them.