From d368b3cf6294832feb7f6ea330ada082249d16e5 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 5 Jan 2014 17:11:24 -0800 Subject: [PATCH] core: Tolerate syntax errors in ~/.gemrc [GH-2760] --- plugins/commands/plugin/gem_helper.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plugins/commands/plugin/gem_helper.rb b/plugins/commands/plugin/gem_helper.rb index b937570b8..e1a1fff91 100644 --- a/plugins/commands/plugin/gem_helper.rb +++ b/plugins/commands/plugin/gem_helper.rb @@ -29,7 +29,15 @@ module VagrantPlugins # Set a custom configuration to avoid loading ~/.gemrc loads and # /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 # Clear the sources so that installation uses custom sources