From de92f5217c7b5e384f66c4058a89af8689ae84aa Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 6 May 2012 10:09:33 -0700 Subject: [PATCH] Use `load` for the Vagrantrc, make sure it is only loaded once --- lib/vagrant/environment.rb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/vagrant/environment.rb b/lib/vagrant/environment.rb index b81c8b8c5..e4fd9313f 100644 --- a/lib/vagrant/environment.rb +++ b/lib/vagrant/environment.rb @@ -1,5 +1,6 @@ -require 'pathname' require 'fileutils' +require 'pathname' +require 'set' require 'log4r' require 'rubygems' # This is needed for plugin loading below. @@ -42,6 +43,10 @@ module Vagrant # The path to the default private key attr_reader :default_private_key_path + # This is a set of the vagrantrc files already loaded so that they + # are only loaded once. + @@loaded_rc = Set.new + # Initializes a new environment with the given options. The options # is a hash where the main available key is `cwd`, which defines where # the environment represents. There are other options available but @@ -521,11 +526,9 @@ module Vagrant # Load the plugins rc_path = File.expand_path(ENV["VAGRANT_RC"] || DEFAULT_RC) - if File.file?(rc_path) - # We use a `require` here instead of a load so the same file will - # only be loaded once. + if File.file?(rc_path) && @@loaded_rc.add?(rc_path) @logger.debug("Loading RC file: #{rc_path}") - require rc_path + load rc_path else @logger.debug("RC file not found. Not loading: #{rc_path}") end