lib/bundler.rb in bundler-1.1.rc vs lib/bundler.rb in bundler-1.1.rc.2
- old
+ new
@@ -1,16 +1,9 @@
require 'rbconfig'
require 'fileutils'
require 'pathname'
-
-begin
- # Pull in Psych if we can, but not if Syck is already loaded
- require 'psych' unless defined?(Syck)
-rescue LoadError
-end
-
-require 'yaml'
+require 'bundler/psyched_yaml'
require 'bundler/rubygems_ext'
require 'bundler/rubygems_integration'
require 'bundler/version'
module Bundler
@@ -234,11 +227,11 @@
def requires_sudo?
return @requires_sudo if defined?(@checked_for_sudo)
path = bundle_path
path = path.parent until path.exist?
- sudo_present = !(`which sudo` rescue '').empty?
+ sudo_present = which "sudo"
bin_dir = Pathname.new(Bundler.system_bindir)
bin_dir = bin_dir.parent until bin_dir.exist?
@checked_for_sudo = true
sudo_gems = !File.writable?(path) || !File.writable?(bin_dir)
@@ -251,10 +244,21 @@
else
FileUtils.mkdir_p(path)
end
end
+ def which(executable)
+ if File.executable?(executable)
+ executable
+ else
+ path = ENV['PATH'].split(File::PATH_SEPARATOR).find { |path|
+ File.executable?(File.join(path, executable))
+ }
+ path && File.expand_path(executable, path)
+ end
+ end
+
def sudo(str)
`sudo -p 'Enter your password to install the bundled RubyGems to your system: ' #{str}`
end
def read_file(file)
@@ -276,11 +280,11 @@
original_line = e.backtrace.find { |line| line.include?(path.to_s) }
msg = "There was a LoadError while evaluating #{path.basename}:\n #{e.message}"
msg << " from\n #{original_line}" if original_line
msg << "\n"
- if RUBY_VERSION >= "1.9.0"
+ if RUBY_VERSION >= "1.9"
msg << "\nDoes it try to require a relative path? That doesn't work in Ruby 1.9."
end
raise GemspecError, msg
end
@@ -292,20 +296,23 @@
def configure_gem_home_and_path
if settings[:disable_shared_gems]
ENV['GEM_PATH'] = ''
ENV['GEM_HOME'] = File.expand_path(bundle_path, root)
+ # TODO: This mkdir_p is only needed for JRuby <= 1.5 and should go away (GH #602)
+ FileUtils.mkdir_p bundle_path.to_s rescue nil
+
+ Bundler.rubygems.clear_paths
elsif Bundler.rubygems.gem_dir != bundle_path.to_s
possibles = [Bundler.rubygems.gem_dir, Bundler.rubygems.gem_path]
paths = possibles.flatten.compact.uniq.reject { |p| p.empty? }
ENV["GEM_PATH"] = paths.join(File::PATH_SEPARATOR)
ENV["GEM_HOME"] = bundle_path.to_s
- end
+ # TODO: This mkdir_p is only needed for JRuby <= 1.5 and should go away (GH #602)
+ FileUtils.mkdir_p bundle_path.to_s rescue nil
- # TODO: This mkdir_p is only needed for JRuby <= 1.5 and should go away (GH #602)
- FileUtils.mkdir_p bundle_path.to_s rescue nil
-
- Bundler.rubygems.clear_paths
+ Bundler.rubygems.clear_paths
+ end
end
def upgrade_lockfile
lockfile = default_lockfile
if lockfile.exist? && lockfile.read(3) == "---"