Skip to content

repo commands: --cache-dir naming a regular file exits 1 with a bare [Errno 17] File exists, not exit 2 naming the flag #765

Open

Description

@antonwolfy

The repo commands pass --cache-dir to open_source (dokimi/dokimi/commands/repo.py:624 _cache_dir), which calls ensure_clone (dokimi/dokimi/repos/source.py:487, cache_dir.mkdir(parents=True, exist_ok=True)) for a remote source.

Repro: python cli.py repo fetch file:///tmp/nothere@HEAD --cache-dir /tmp/cachefile, where /tmp/cachefile is a regular file. Output: ✗ [Errno 17] File exists: '/tmp/cachefile', exit 1 (with --json: "status": "failed", "reason": "exit 1: see stderr"). Calling ensure_clone(url, Path('/tmp/cachefile')) directly raises FileExistsError. There is no traceback, but a bad flag value reads as a failed run: the message does not name --cache-dir, and the exit code is 1 where bad input is 2.

The same cause as #701 (an unusable cache directory reaching an unguarded mkdir), in a different cache.

Fix options: validate --cache-dir in _cache_dir and raise InputError naming the flag and path (the check usable_cache_dir in commands/novelty_run.py can move to a shared place and be reused), or catch OSError in ensure_clone and re-raise as SourceError naming the directory. The first fails before any clone starts.

Found while fixing #701. The fix's PR is #766.

Activity

  1. self-assigned this
    on Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions