diff --git a/helics/cli.py b/helics/cli.py index 9ef72f8..8ae776f 100644 --- a/helics/cli.py +++ b/helics/cli.py @@ -13,6 +13,7 @@ import platform import urllib.request import logging +import shutil from ._version import __version__ from .status_checker import CheckStatusThread @@ -305,8 +306,14 @@ def run(path, silent, connect_server, no_log_files, no_kill_on_error): if "env" in f: for k, v in f["env"].items(): env[k] = v + p_args = shlex.split(f["exec"]) + p_args[0] = shutil.which(p_args[0]) + if p_args[0] is None: + raise click.ClickException("UnrecognizedCommandError: The command specified in exec string is not a " + "recognized command in the system. The user provided exec string is " + f"{f['exec']}.") p = subprocess.Popen( - shlex.split(f["exec"]), + p_args, cwd=os.path.abspath(os.path.expanduser(directory)), stdout=o.file, stderr=o.file,