From 3e46e8bcb7a4a2f3c7dc507da15a384e78f4b695 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Tue, 11 Oct 2016 10:47:08 -0700 Subject: [PATCH] core: Rescue EINVAL exceptions when loading bundler --- bin/vagrant | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/bin/vagrant b/bin/vagrant index b9ef5feee..8319fef1f 100755 --- a/bin/vagrant +++ b/bin/vagrant @@ -66,7 +66,22 @@ end # Setup our dependencies by initializing Bundler. If we're using plugins, # then also initialize the paths to the plugins. -require "bundler" +begin + require "bundler" +rescue Errno::EINVAL + # Bundler can generated the EINVAL error during initial require, which means + # nothing has yet been setup (so no access to I18n). Note that vagrant has + # failed early and copy information related to problem and possible solution. + $stderr.puts "Vagrant failed to initialize at a very early stage:\n\n" + $stderr.puts "Vagrant received an "EINVAL" error while attempting to set some" + $stderr.puts "environment variables. This is usually caused by the total size of your" + $stderr.puts "environment variables being too large. Vagrant sets a handful of" + $stderr.puts "environment variables to function and requires this to work. Please" + $stderr.puts "delete some environment variables prior to executing Vagrant to" + $stderr.puts "fix this." + exit 255 +end + begin $vagrant_bundler_runtime = Bundler.setup(:default, :plugins) rescue Bundler::GemNotFound