Prior to this commit, when Vagrant attempted to use the Gem library, it would attempt to pass in a gemrc through an environment variable that the rubygems library would try to split and parse. This is normally fine, as the method in question would return empty if that file did not exist. However if the user had a file that matches the drive that Vagrant was installed on, rubygems would fail saying the folder was not a file (or a gemrc, in this case). This commit works around that by instead configuring the gemrc location through ruby with `Gem.configuration`. Related rubygems issue [#2733](https://github.com/rubygems/rubygems/issues/2733)
This commit is contained in:
parent
ad342e2bf0
commit
e2097be55e
|
@ -12,6 +12,8 @@ require "rubygems/name_tuple"
|
|||
require_relative "shared_helpers"
|
||||
require_relative "version"
|
||||
require_relative "util/safe_env"
|
||||
require_relative "util/platform"
|
||||
require "vagrant/util/subprocess"
|
||||
|
||||
module Vagrant
|
||||
# This class manages Vagrant's interaction with Bundler. Vagrant uses
|
||||
|
@ -40,6 +42,17 @@ module Vagrant
|
|||
def initialize
|
||||
@plugin_gem_path = Vagrant.user_data_path.join("gems", RUBY_VERSION).freeze
|
||||
@logger = Log4r::Logger.new("vagrant::bundler")
|
||||
|
||||
# Because of a rubygems bug, we need to set the gemrc file path
|
||||
# through this method rather than relying on the environment varible
|
||||
# GEMRC. On windows, that path gets split on `:`: and `;`, which means
|
||||
# the drive letter gets treated as its own path. If that path exists locally,
|
||||
# (like having a random folder called `c` where the library was invoked),
|
||||
# it fails thinking the folder `c` is a gemrc file.
|
||||
gemrc_val = ENV["GEMRC"]
|
||||
ENV["GEMRC"] = ""
|
||||
Gem.configuration = Gem::ConfigFile.new(["--config-file", gemrc_val])
|
||||
ENV["GEMRC"] = gemrc_val
|
||||
end
|
||||
|
||||
# Enable Vagrant environment specific plugins at given data path
|
||||
|
|
Loading…
Reference in New Issue