From 7672360fc101d8d06469141c51b1439653299fcc Mon Sep 17 00:00:00 2001 From: Zhanghao Wu Date: Thu, 4 Apr 2024 21:03:30 -0700 Subject: [PATCH] [Core] Error out for a non-exist SKYPILOT_CONFIG (#3423) * Error out for a non-exist CONFIG_PATH * expanduser for the config yaml --- sky/skypilot_config.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sky/skypilot_config.py b/sky/skypilot_config.py index 06379e5a3d2..0d950bf6e98 100644 --- a/sky/skypilot_config.py +++ b/sky/skypilot_config.py @@ -51,6 +51,7 @@ from sky import sky_logging from sky.utils import common_utils from sky.utils import schemas +from sky.utils import ux_utils # The config path is discovered in this order: # @@ -128,7 +129,14 @@ def _try_load_config() -> None: global _dict, _loaded_config_path config_path_via_env_var = os.environ.get(ENV_VAR_SKYPILOT_CONFIG) if config_path_via_env_var is not None: - config_path = config_path_via_env_var + config_path = os.path.expanduser(config_path_via_env_var) + if not os.path.exists(config_path): + with ux_utils.print_exception_no_traceback(): + raise FileNotFoundError( + 'Config file specified by env var ' + f'{ENV_VAR_SKYPILOT_CONFIG} ({config_path!r}) does not ' + 'exist. Please double check the path or unset the env var: ' + f'unset {ENV_VAR_SKYPILOT_CONFIG}') else: config_path = CONFIG_PATH config_path = os.path.expanduser(config_path)