diff --git a/esmvalcore/_task.py b/esmvalcore/_task.py index 2a908583b6..d96b40f9af 100644 --- a/esmvalcore/_task.py +++ b/esmvalcore/_task.py @@ -386,9 +386,15 @@ def _initialize_cmd(self): """Create an executable command from script.""" diagnostics_root = DIAGNOSTICS.scripts script = self.script - script_file = (diagnostics_root / Path(script).expanduser()).absolute() + # Check if local diagnostic path exists + script_file = Path(script).expanduser().absolute() err_msg = f"Cannot execute script '{script}' ({script_file})" + if not script_file.is_file(): + # Try diagnostics_root + script_file = ( + diagnostics_root / Path(script).expanduser() + ).absolute() if not script_file.is_file(): raise DiagnosticError(f"{err_msg}: file does not exist.")