Skip to content

[BUG] OpenClaw: apc sync crashes with [Errno 17] File exists when skill exists as a symlink #33

Description

@FZ2000

Tool Affected

openclaw

What Happened

Running apc sync --all --yes when ~/.openclaw/skills/test-skill exists as a symlink (from a previous apc install) crashes with:

✗ Failed to apply to openclaw: [Errno 17] File exists: '/Users/frank/.openclaw/skills/test-skill'

The entire openclaw sync fails — no skills written, no memory synced.

Steps to Reproduce

  1. Run apc install <some-repo> --skill test-skill --target openclaw
    → Creates ~/.openclaw/skills/test-skill as a symlink to ~/.apc/skills/test-skill
  2. Run apc sync --all --yes
    → Crashes with [Errno 17] File exists

Root Cause

In src/appliers/openclaw.py, apply_skills() does:

skill_dir = _openclaw_skills_dir() / name
skill_dir.mkdir(parents=True, exist_ok=True)  # <-- fails if path is a symlink

Path.mkdir(exist_ok=True) raises FileExistsError (errno 17) when the path is an existing symlink pointing to a directory — it does not treat symlinks as directories. The symlink was created by link_skills() in base.py, and apply_skills() has no code to handle this case.

What Was Expected

  • apply_skills() should detect if the target path is a symlink and either:
    • Skip it (if the linked content is current), or
    • Remove the symlink and write the skill directory directly

Suggested Fix

skill_dir = _openclaw_skills_dir() / name
if skill_dir.is_symlink():
    skill_dir.unlink()  # remove symlink before mkdir
skill_dir.mkdir(parents=True, exist_ok=True)

Additional Context

After this crash, apc status still shows ● synced for openclaw — the manifest was not updated to reflect the failure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions