From 159e1ec1f12c821b73a8d45500a4545415e310f4 Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Sun, 29 May 2016 00:41:59 -0400 Subject: [PATCH] Use a real file for bundler --- lib/vagrant/bundler.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/vagrant/bundler.rb b/lib/vagrant/bundler.rb index 13fe174d1..5ed499abf 100644 --- a/lib/vagrant/bundler.rb +++ b/lib/vagrant/bundler.rb @@ -254,13 +254,14 @@ module Vagrant def with_isolated_gem raise Errors::BundlerDisabled if !@enabled - tmp_gemfile = Dir::Tmpname.create("vagrant-gemfile") {} + tmp_gemfile = tempfile("vagrant-gemfile") + tmp_gemfile.close # Remove bundler settings so that Bundler isn't loaded when building # native extensions because it causes all sorts of problems. old_rubyopt = ENV["RUBYOPT"] old_gemfile = ENV["BUNDLE_GEMFILE"] - ENV["BUNDLE_GEMFILE"] = tmp_gemfile + ENV["BUNDLE_GEMFILE"] = tmp_gemfile.path ENV["RUBYOPT"] = (ENV["RUBYOPT"] || "").gsub(/-rbundler\/setup\s*/, "") # Set the GEM_HOME so gems are installed only to our local gem dir @@ -290,7 +291,7 @@ module Vagrant return yield end ensure - File.unlink(tmp_gemfile) if File.file?(tmp_gemfile) + tmp_gemfile.unlink rescue nil ENV["BUNDLE_GEMFILE"] = old_gemfile ENV["GEM_HOME"] = @gem_home