core: Tolerate syntax errors in ~/.gemrc [GH-2760]

This commit is contained in:
Mitchell Hashimoto 2014-01-05 17:11:24 -08:00
parent 2fd144611e
commit d368b3cf62
1 changed files with 9 additions and 1 deletions

View File

@ -29,7 +29,15 @@ module VagrantPlugins
# Set a custom configuration to avoid loading ~/.gemrc loads and # Set a custom configuration to avoid loading ~/.gemrc loads and
# /etc/gemrc and so on. # /etc/gemrc and so on.
old_config = Gem.configuration old_config = nil
begin
old_config = Gem.configuration
rescue Psych::SyntaxError
# Just ignore this. This means that the ".gemrc" file has
# an invalid syntax and can't be loaded. We don't care, because
# when we set Gem.configuration to nil later, it'll force a reload
# if it is needed.
end
Gem.configuration = NilGemConfig.new Gem.configuration = NilGemConfig.new
# Clear the sources so that installation uses custom sources # Clear the sources so that installation uses custom sources