core: Rescue EINVAL exceptions when loading bundler

This commit is contained in:
Chris Roberts 2016-10-11 10:47:08 -07:00
parent 2c9c458e42
commit 3e46e8bcb7
1 changed files with 16 additions and 1 deletions

View File

@ -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