affaan-m/ECC · error · ValueError

Path does not exist

Error message

Path does not exist: {path}

What it means

Raised by _validate_file_path when must_exist is true and pathlib.Path.exists() returns False for the supplied path. The import/export commands require the target file to already be present before reading or validating it. It is a plain existence check that runs after the system-prefix blocklist.

Solutions

  1. Verify the file exists (Path(path).exists()) and correct any typo in the path.
  2. Run the command from the intended working directory or use an absolute path.
  3. Create the file first (e.g. export instincts before a later import step).
  4. Wrap the command and catch the ValueError to print a friendly 'file not found' message.

Example fix

# before
subprocess.run(["python", "instinct-cli.py", "import", "--file", "instincts.yaml"])  # wrong cwd
# after
from pathlib import Path
src = Path.home() / ".config/ecc-instincts/instincts.yaml"
assert src.exists(), f"missing input: {src}"
subprocess.run(["python", "instinct-cli.py", "import", "--file", str(src)])
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path
p = Path(path)
if not p.exists():
    raise FileNotFoundError(p)

Try / catch

try:
    cli_import(file=path)
except ValueError as e:
    if "does not exist" in str(e):
        print(f"input file missing: {path}")

Prevention

When it happens

Trigger: Calling cmd_import/cmd_export with a file path that does not exist on disk while must_exist is enabled — e.g. a misspelled filename, wrong working directory, or a file deleted between planning and running the command.

Common situations: Running the CLI from a different cwd than the script author assumed so a relative path no longer resolves; typo in the path; file removed by a cleanup job or not yet generated by a prior step.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16). Data as JSON: /api/errors/184feb335270e8c0. Report an issue: GitHub.

Appendix: source

Thrown at skills/continuous-learning-v2/scripts/instinct-cli.py:171

    """
    path = Path(path_str).expanduser().resolve()

    # Block paths that escape into system directories
    # We block specific system paths but allow temp dirs (/var/folders on macOS)
    blocked_prefixes = [
        "/etc", "/usr", "/bin", "/sbin", "/proc", "/sys",
        "/var/log", "/var/run", "/var/lib", "/var/spool",
        # macOS resolves /etc → /private/etc
        "/private/etc",
        "/private/var/log", "/private/var/run", "/private/var/db",
    ]
    path_s = str(path)
    for prefix in blocked_prefixes:
        if path_s.startswith(prefix + "/") or path_s == prefix:
            raise ValueError(f"Path '{path}' targets a system directory")

    if must_exist and not path.exists():
        raise ValueError(f"Path does not exist: {path}")

    return path


def _validate_instinct_id(instinct_id: str) -> bool:
    """Validate instinct IDs before using them in filenames."""
    if not instinct_id or len(instinct_id) > 128:
        return False
    if "/" in instinct_id or "\\" in instinct_id:
        return False
    if ".." in instinct_id:
        return False
    if instinct_id.startswith("."):
        return False
    return bool(re.match(r"^[A-Za-z0-9][A-Za-z0-9._-]*$", instinct_id))


def _validate_import_url(source: str) -> str:

View on GitHub (pinned to 8321021c54)