Skip to content

Commit 23e5c64

Browse files
authored
On run with replace, warn if executable not found (#271)
1 parent 7d4fcd8 commit 23e5c64

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

spin/cmds/util.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import copy
66
import os
77
import shlex
8+
import shutil
89
import subprocess
910
import sys
1011
from collections.abc import Callable
@@ -65,8 +66,15 @@ def run(
6566
kwargs = {**output_kwargs, **kwargs}
6667

6768
if replace and (sys.platform in ("linux", "darwin")):
69+
if not shutil.which(cmd[0]):
70+
click.secho(
71+
f"`{cmd[0]}` executable not found; exiting.",
72+
fg="bright_red",
73+
)
74+
raise SystemExit(1) from None
75+
6876
os.execvp(cmd[0], cmd)
69-
print(f"Failed to launch `{cmd}`")
77+
print(f"Failed to launch `{cmd}`; exiting.")
7078
sys.exit(-1)
7179
else:
7280
try:

0 commit comments

Comments
 (0)