Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make bundler/setup something you can add to your .profile. To do this…

…, add -I/path/to/bundler -rbundler/setup to your RUBYOPT
  • Loading branch information...
commit fb1e725aa4e1902061b22c3d3482d0309188abc9 1 parent f7bfdde
Carlhuda authored
View
18 lib/bundler.rb
@@ -107,24 +107,12 @@ def settings
@settings ||= Settings.new(root)
end
- def default_gemfile
- if ENV['BUNDLE_GEMFILE']
- return Pathname.new(ENV['BUNDLE_GEMFILE'])
- end
-
- current = Pathname.new(Dir.pwd)
-
- until current.root?
- filename = current.join("Gemfile")
- return filename if filename.exist?
- current = current.parent
- end
+ private
- raise GemfileNotFound, "The default Gemfile was not found"
+ def default_gemfile
+ SharedHelpers.default_gemfile
end
- private
-
def configure_gem_home_and_path
if path = settings[:path]
ENV['GEM_HOME'] = File.expand_path(path, root)
View
19 lib/bundler/cli.rb
@@ -105,7 +105,7 @@ def exec(*)
ENV["PATH"] = paths.uniq.join(File::PATH_SEPARATOR)
# Set BUNDLE_GEMFILE
- ENV['BUNDLE_GEMFILE'] = Bundler.default_gemfile.to_s
+ ENV['BUNDLE_GEMFILE'] = Bundler::SharedHelpers.default_gemfile.to_s
# Set RUBYOPT
rubyopt = [ENV["RUBYOPT"]].compact
@@ -117,14 +117,15 @@ def exec(*)
Kernel.exec *ARGV
end
- private
- def locked?
- File.exist?("#{Bundler.root}/Gemfile.lock") || File.exist?("#{Bundler.root}/.bundle/environment.rb")
- end
+ private
- def remove_lockfiles
- FileUtils.rm_f "#{Bundler.root}/Gemfile.lock"
- FileUtils.rm_f "#{Bundler.root}/.bundle/environment.rb"
- end
+ def locked?
+ File.exist?("#{Bundler.root}/Gemfile.lock") || File.exist?("#{Bundler.root}/.bundle/environment.rb")
+ end
+
+ def remove_lockfiles
+ FileUtils.rm_f "#{Bundler.root}/Gemfile.lock"
+ FileUtils.rm_f "#{Bundler.root}/.bundle/environment.rb"
+ end
end
end
View
8 lib/bundler/setup.rb
@@ -1,3 +1,9 @@
+# This is not actually required by the actual library
require 'bundler'
-Bundler.setup
+if Bundler::SharedHelpers.in_bundle?
+ require 'rubygems'
+ require 'bundler'
+
+ Bundler.setup
+end
View
23 lib/bundler/shared_helpers.rb
@@ -15,5 +15,28 @@ def reverse_rubygems_kernel_mixin
end
end
+ def default_gemfile
+ if ENV['BUNDLE_GEMFILE']
+ return Pathname.new(ENV['BUNDLE_GEMFILE'])
+ end
+
+ current = Pathname.new(Dir.pwd)
+
+ until current.root?
+ filename = current.join("Gemfile")
+ return filename if filename.exist?
+ current = current.parent
+ end
+
+ raise GemfileNotFound, "The default Gemfile was not found"
+ end
+
+ def in_bundle?
+ default_gemfile
+ rescue GemfileNotFound
+ false
+ end
+
+ extend self
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.