lib/bundler.rb in bundler-1.16.2 vs lib/bundler.rb in bundler-1.16.3

- old
+ new

@@ -157,16 +157,17 @@ end def user_home @user_home ||= begin home = Bundler.rubygems.user_home + bundle_home = home ? File.join(home, ".bundle") : nil warning = if home.nil? "Your home directory is not set." elsif !File.directory?(home) "`#{home}` is not a directory." - elsif !File.writable?(home) + elsif !File.writable?(home) && (!File.directory?(bundle_home) || !File.writable?(bundle_home)) "`#{home}` is not writable." end if warning user_home = tmp_home_path(Etc.getlogin, warning) @@ -357,12 +358,12 @@ @requires_sudo_ran = true @requires_sudo = settings.allow_sudo? && sudo_present && sudo_needed end - def mkdir_p(path) - if requires_sudo? + def mkdir_p(path, options = {}) + if requires_sudo? && !options[:no_sudo] sudo "mkdir -p '#{path}'" unless File.exist?(path) else SharedHelpers.filesystem_access(path, :write) do |p| FileUtils.mkdir_p(p) end @@ -405,11 +406,13 @@ `sudo -p "#{prompt}" #{str}` end end def read_file(file) - File.open(file, "rb", &:read) + SharedHelpers.filesystem_access(file, :read) do + File.open(file, "rb", &:read) + end end def load_marshal(data) Marshal.load(data) rescue => e @@ -425,10 +428,10 @@ @gemspec_cache[key].dup if @gemspec_cache[key] end def load_gemspec_uncached(file, validate = false) path = Pathname.new(file) - contents = read_file(file) + contents = File.open(file, "r:UTF-8", &:read) spec = if contents.start_with?("---") # YAML header eval_yaml_gemspec(path, contents) else # Eval the gemspec from its parent directory, because some gemspecs # depend on "./" relative paths.