Skip to content

Commit 5668ce3

Browse files
committed
Improved error message when VirtualBox is not installed
Signed-off-by: Ole Herman Schumacher Elgesem <ole.elgesem@northern.tech>
1 parent 72ea955 commit 5668ce3

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

cf_remote/spawn.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
from cf_remote.cloud_data import aws_image_criteria, aws_defaults
2222
from cf_remote.paths import cf_remote_dir, CLOUD_STATE_FPATH
23-
from cf_remote.utils import whoami, copy_file, canonify, read_json
23+
from cf_remote.utils import CFRUserError, whoami, copy_file, canonify, read_json
2424
from cf_remote import log
2525
from cf_remote import cloud_data
2626

@@ -822,10 +822,25 @@ def spawn_vm_in_vagrant(
822822
command_args.append("--no-provision")
823823

824824
log.debug("Starting the VM(s)")
825-
result = subprocess.run(command_args, env=vagrant_env, stderr=subprocess.PIPE)
825+
try:
826+
result = subprocess.run(command_args, env=vagrant_env, stderr=subprocess.PIPE)
827+
except FileNotFoundError as e:
828+
raise CFRUserError(
829+
"'vagrant' not found - go to https://www.vagrantup.com/downloads to download and install vagrant ({}).".format(
830+
e
831+
)
832+
)
826833

827834
if result.returncode != 0:
828-
raise Exception(result.stderr.decode())
835+
print()
836+
log.error(result.stderr.decode())
837+
raise CFRUserError(
838+
(
839+
"vagrant exited with error code {}"
840+
+ " - Make sure you have a working vagrant setup, install VirtualBox if you haven't already: "
841+
+ "https://www.virtualbox.org/wiki/Downloads"
842+
).format(result.returncode)
843+
)
829844

830845
log.debug("Copying vagrant ssh config")
831846

0 commit comments

Comments
 (0)