Skip to content

Commit

Permalink
Don't fallback to tempdir when required directories exist.
Browse files Browse the repository at this point in the history
When home directory is not writable, but the required .gem and .bundle
are, we should use them instead of falling back to use tempdirs.

This creates a workaround for more restrictive setups using Omnibus
Docker or any hardened setup, to overcome the annoyances introduced by rubygems#4951.
  • Loading branch information
brodock committed May 23, 2018
1 parent c793c38 commit 2d051a6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/bundler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,13 @@ def ruby_scope
def user_home
@user_home ||= begin
home = Bundler.rubygems.user_home
user_dirs = %w[.bundle .gem].map {|path| Pathname.new(home).join(path)}

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) && user_dirs.any? {|path| !path.directory? || !path.writable?}
"`#{home}` is not writable."
end

Expand Down

0 comments on commit 2d051a6

Please sign in to comment.