lib/bundler.rb in bundler-1.3.6 vs lib/bundler.rb in bundler-1.4.0.pre.1
- old
+ new
@@ -3,10 +3,12 @@
require 'rbconfig'
require 'bundler/gem_path_manipulation'
require 'bundler/rubygems_ext'
require 'bundler/rubygems_integration'
require 'bundler/version'
+require 'bundler/constants'
+require 'bundler/current_ruby'
module Bundler
preserve_gem_path
ORIGINAL_ENV = ENV.to_hash
@@ -46,30 +48,27 @@
def self.status_code(code)
define_method(:status_code) { code }
end
end
- class GemfileNotFound < BundlerError; status_code(10) ; end
- class GemNotFound < BundlerError; status_code(7) ; end
- class GemfileError < BundlerError; status_code(4) ; end
- class InstallError < BundlerError; status_code(5) ; end
- class InstallHookError < BundlerError; status_code(6) ; end
- class PathError < BundlerError; status_code(13) ; end
- class GitError < BundlerError; status_code(11) ; end
- class DeprecatedError < BundlerError; status_code(12) ; end
- class GemspecError < BundlerError; status_code(14) ; end
- class InvalidOption < BundlerError; status_code(15) ; end
- class ProductionError < BundlerError; status_code(16) ; end
- class HTTPError < BundlerError; status_code(17) ; end
- class RubyVersionMismatch < BundlerError; status_code(18) ; end
- class SecurityError < BundlerError; status_code(19) ; end
- class LockfileError < BundlerError; status_code(20) ; end
+ class GemfileNotFound < BundlerError; status_code(10) ; end
+ class GemNotFound < BundlerError; status_code(7) ; end
+ class GemfileError < BundlerError; status_code(4) ; end
+ class InstallError < BundlerError; status_code(5) ; end
+ class InstallHookError < BundlerError; status_code(6) ; end
+ class PathError < BundlerError; status_code(13) ; end
+ class GitError < BundlerError; status_code(11) ; end
+ class DeprecatedError < BundlerError; status_code(12) ; end
+ class GemspecError < BundlerError; status_code(14) ; end
+ class InvalidOption < BundlerError; status_code(15) ; end
+ class ProductionError < BundlerError; status_code(16) ; end
+ class HTTPError < BundlerError; status_code(17) ; end
+ class RubyVersionMismatch < BundlerError; status_code(18) ; end
+ class SecurityError < BundlerError; status_code(19) ; end
+ class LockfileError < BundlerError; status_code(20) ; end
+ class CyclicDependencyError < BundlerError; status_code(21) ; end
- WINDOWS = RbConfig::CONFIG["host_os"] =~ %r!(msdos|mswin|djgpp|mingw)!
- FREEBSD = RbConfig::CONFIG["host_os"] =~ /bsd/
- NULL = WINDOWS ? "NUL" : "/dev/null"
-
# Internal errors, should be rescued
class VersionConflict < BundlerError
attr_reader :conflicts
def initialize(conflicts, msg = nil)
@@ -137,10 +136,15 @@
def environment
Bundler::Environment.new(root, definition)
end
+ # Returns an instance of Bundler::Definition for given Gemfile and lockfile
+ #
+ # @param unlock [Hash, Boolean, nil] Gems that have been requested
+ # to be updated or true if all gems should be updated
+ # @return [Bundler::Definition]
def definition(unlock = nil)
@definition = nil if unlock
@definition ||= begin
configure
upgrade_lockfile
@@ -287,11 +291,23 @@
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}`
+ prompt = "\n\n" + <<-PROMPT.gsub(/^ {6}/, '').strip + " "
+ Your user account isn't allowed to install to the system Rubygems.
+ You can cancel this installation and run:
+
+ bundle install --path vendor/bundle
+
+ to install the gems into ./vendor/bundle/, or you can enter your password
+ and install the bundled gems to Rubygems using sudo.
+
+ Password:
+ PROMPT
+
+ `sudo -p "#{prompt}" #{str}`
end
def read_file(file)
File.open(file, "rb") { |f| f.read }
end
@@ -313,10 +329,10 @@
def load_gemspec_uncached(file)
path = Pathname.new(file)
# Eval the gemspec from its parent directory, because some gemspecs
# depend on "./" relative paths.
- Dir.chdir(path.dirname.to_s) do
+ SharedHelpers.chdir(path.dirname.to_s) do
contents = path.read
if contents[0..2] == "---" # YAML header
eval_yaml_gemspec(path, contents)
else
eval_gemspec(path, contents)