Update serve mode setup to prevent environment loading
This commit is contained in:
parent
96ac78a9a4
commit
e56b2df70d
102
bin/vagrant
102
bin/vagrant
@ -194,65 +194,65 @@ begin
|
|||||||
end
|
end
|
||||||
}.new(argv.dup, nil).sub_command
|
}.new(argv.dup, nil).sub_command
|
||||||
|
|
||||||
# Check if we are running the server
|
# Check if we are running the server. If we are, we extract
|
||||||
|
# the command from the plugin manager and run it directly.
|
||||||
|
# Doing this prevents Vagrant from attempting to load an
|
||||||
|
# Environment directly.
|
||||||
if sub_cmd == "serve"
|
if sub_cmd == "serve"
|
||||||
Vagrant.enable_server_mode!
|
Vagrant.enable_server_mode!
|
||||||
# NOTE: We stub the client option to allow the environment to
|
cmd = Vagrant.plugin("2").manager.commands[:serve].first.call
|
||||||
# be initialized for startup since it will raise an
|
result = cmd.new([], nil).execute
|
||||||
# exception if it is unset. We don't care about the
|
exit(result)
|
||||||
# initially created environment, we just need it long
|
else
|
||||||
# enough for our serve command to get executed.
|
# Create the environment, which is the cwd of wherever the
|
||||||
opts[:client] = :stub
|
# `vagrant` command was invoked from
|
||||||
end
|
logger.debug("Creating Vagrant environment")
|
||||||
|
env = klass.new(opts)
|
||||||
|
|
||||||
# Create the environment, which is the cwd of wherever the
|
# If we are running with the Windows Subsystem for Linux do
|
||||||
# `vagrant` command was invoked from
|
# some extra setup to allow access to Vagrant managed machines
|
||||||
logger.debug("Creating Vagrant environment")
|
# outside the subsystem
|
||||||
env = Vagrant::Environment.new(opts)
|
if Vagrant::Util::Platform.wsl?
|
||||||
|
recreate_env = Vagrant::Util::Platform.wsl_init(env, logger)
|
||||||
# If we are running with the Windows Subsystem for Linux do
|
if recreate_env
|
||||||
# some extra setup to allow access to Vagrant managed machines
|
logger.info("Re-creating Vagrant environment due to WSL modifications.")
|
||||||
# outside the subsystem
|
env = Vagrant::Environment.new(opts)
|
||||||
if Vagrant::Util::Platform.wsl?
|
end
|
||||||
recreate_env = Vagrant::Util::Platform.wsl_init(env, logger)
|
|
||||||
if recreate_env
|
|
||||||
logger.info("Re-creating Vagrant environment due to WSL modifications.")
|
|
||||||
env = Vagrant::Environment.new(opts)
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
if !Vagrant.in_installer? && !Vagrant.very_quiet?
|
if !Vagrant.in_installer? && !Vagrant.very_quiet?
|
||||||
# If we're not in the installer, warn.
|
# If we're not in the installer, warn.
|
||||||
env.ui.warn(I18n.t("vagrant.general.not_in_installer") + "\n", prefix: false)
|
env.ui.warn(I18n.t("vagrant.general.not_in_installer") + "\n", prefix: false)
|
||||||
end
|
|
||||||
|
|
||||||
# Acceptable experimental flag values include:
|
|
||||||
#
|
|
||||||
# Unset - Disables experimental features
|
|
||||||
# 0 - Disables experimental features
|
|
||||||
# 1 - Enables all features
|
|
||||||
# String - Enables one or more features, separated by commas
|
|
||||||
if Vagrant::Util::Experimental.enabled?
|
|
||||||
experimental = Vagrant::Util::Experimental.features_requested
|
|
||||||
ui = Vagrant::UI::Prefixed.new(env.ui, "vagrant")
|
|
||||||
logger.debug("Experimental flag is enabled")
|
|
||||||
if Vagrant::Util::Experimental.global_enabled?
|
|
||||||
ui.warn(I18n.t("vagrant.general.experimental.all"), bold: true, prefix: true, channel: :error)
|
|
||||||
else
|
|
||||||
ui.warn(I18n.t("vagrant.general.experimental.features", features: experimental.join(", ")), bold: true, prefix: true, channel: :error)
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
begin
|
# Acceptable experimental flag values include:
|
||||||
# Execute the CLI interface, and exit with the proper error code
|
#
|
||||||
exit_status = env.cli(argv)
|
# Unset - Disables experimental features
|
||||||
ensure
|
# 0 - Disables experimental features
|
||||||
# Unload the environment so cleanup can be done
|
# 1 - Enables all features
|
||||||
env.unload
|
# String - Enables one or more features, separated by commas
|
||||||
end
|
if Vagrant::Util::Experimental.enabled?
|
||||||
|
experimental = Vagrant::Util::Experimental.features_requested
|
||||||
|
ui = Vagrant::UI::Prefixed.new(env.ui, "vagrant")
|
||||||
|
logger.debug("Experimental flag is enabled")
|
||||||
|
if Vagrant::Util::Experimental.global_enabled?
|
||||||
|
ui.warn(I18n.t("vagrant.general.experimental.all"), bold: true, prefix: true, channel: :error)
|
||||||
|
else
|
||||||
|
ui.warn(I18n.t("vagrant.general.experimental.features", features: experimental.join(", ")), bold: true, prefix: true, channel: :error)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Exit with the exit status from our CLI command
|
begin
|
||||||
exit(exit_status)
|
# Execute the CLI interface, and exit with the proper error code
|
||||||
|
exit_status = env.cli(argv)
|
||||||
|
ensure
|
||||||
|
# Unload the environment so cleanup can be done
|
||||||
|
env.unload
|
||||||
|
end
|
||||||
|
|
||||||
|
# Exit with the exit status from our CLI command
|
||||||
|
exit(exit_status)
|
||||||
|
end
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
# It is possible for errors to happen in Vagrant's initialization. In
|
# It is possible for errors to happen in Vagrant's initialization. In
|
||||||
# this case, we don't have access to this class yet, so we check for it.
|
# this case, we don't have access to this class yet, so we check for it.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user