core: catch EINVAL on setting env vars [GH-6017]
This commit is contained in:
parent
4e1ba3a027
commit
1405395d81
|
@ -72,6 +72,7 @@ BUG FIXES:
|
|||
retry from scratch [GH-4479]
|
||||
- core: line numbers show properly in Vagrantfile syntax errors
|
||||
on Windows [GH-6445]
|
||||
- core: catch errors setting env vars on Windows [GH-6017]
|
||||
- commands/box: add command with `~` paths on Windows works [GH-5747]
|
||||
- commands/box: the update command supports CA settings [GH-4473]
|
||||
- commands/box: removing all versions and providers of a box will properly
|
||||
|
|
|
@ -7,6 +7,7 @@ require "bundler"
|
|||
|
||||
require_relative "shared_helpers"
|
||||
require_relative "version"
|
||||
require_relative "util/safe_env"
|
||||
|
||||
module Vagrant
|
||||
# This class manages Vagrant's interaction with Bundler. Vagrant uses
|
||||
|
@ -71,12 +72,15 @@ module Vagrant
|
|||
# we add all our plugin dependencies.
|
||||
@gemfile = build_gemfile(plugins)
|
||||
|
||||
# Set the environmental variables for Bundler
|
||||
ENV["BUNDLE_APP_CONFIG"] = @appconfigpath
|
||||
ENV["BUNDLE_CONFIG"] = @configfile.path
|
||||
ENV["BUNDLE_GEMFILE"] = @gemfile.path
|
||||
ENV["GEM_PATH"] =
|
||||
"#{bundle_path}#{::File::PATH_SEPARATOR}#{@gem_path}"
|
||||
SafeEnv.change_env do |env|
|
||||
# Set the environmental variables for Bundler
|
||||
env["BUNDLE_APP_CONFIG"] = @appconfigpath
|
||||
env["BUNDLE_CONFIG"] = @configfile.path
|
||||
env["BUNDLE_GEMFILE"] = @gemfile.path
|
||||
env["GEM_PATH"] =
|
||||
"#{bundle_path}#{::File::PATH_SEPARATOR}#{@gem_path}"
|
||||
end
|
||||
|
||||
Gem.clear_paths
|
||||
end
|
||||
|
||||
|
|
|
@ -344,6 +344,10 @@ module Vagrant
|
|||
error_key(:downloader_interrupted)
|
||||
end
|
||||
|
||||
class EnvInval < VagrantError
|
||||
error_key(:env_inval)
|
||||
end
|
||||
|
||||
class EnvironmentNonExistentCWD < VagrantError
|
||||
error_key(:environment_non_existent_cwd)
|
||||
end
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
module Vagrant
|
||||
module Util
|
||||
class SafeEnv
|
||||
# This yields an environment hash to change and catches any issues
|
||||
# while changing the environment variables and raises a helpful error
|
||||
# to end users.
|
||||
def self.change_env
|
||||
yield ENV
|
||||
rescue Errno::EINVAL
|
||||
raise Errors::EnvInval
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -730,6 +730,13 @@ en:
|
|||
downloader_interrupted: |-
|
||||
The download was interrupted by an external signal. It did not
|
||||
complete.
|
||||
env_inval: |-
|
||||
Vagrant received an "EINVAL" error while attempting to set some
|
||||
environment variables. This is usually caused by the total size of your
|
||||
environment variables being too large. Vagrant sets a handful of
|
||||
environment variables to function and requires this to work. Please
|
||||
delete some environment variables prior to executing Vagrant to
|
||||
fix this.
|
||||
environment_locked: |-
|
||||
Vagrant attempted to acquire a lock named '%{name}', but this
|
||||
lock is being held by another instance of Vagrant already. Please
|
||||
|
|
Loading…
Reference in New Issue