langchain-ai/deepagents · error · SystemExit
Error: Failed to fully delete skill: {e} Warning: Some files
Error message
Error: Failed to fully delete skill: {e} Warning: Some files may have been partially removed. Please inspect: {skill_dir}/ What it means
After validation passes, `_delete` calls `shutil.rmtree(skill_dir)`. If the OS raises `OSError` (permission denied, read-only filesystem, files held open, etc.) some files may already have been removed, so the command prints a combined error plus a partial-removal warning, points the user at the leftover directory, and raises `SystemExit(1)` from the original exception.
Source
Thrown at libs/code/deepagents_code/skills/commands.py:851
"Refusing to delete for safety."
)
raise SystemExit(1)
is_valid_path, path_error = _validate_skill_path(skill_dir, base_dir)
if not is_valid_path:
console.print(f"[bold red]Error:[/bold red] {path_error}")
raise SystemExit(1)
# Delete the skill directory
try:
shutil.rmtree(skill_dir)
except OSError as e:
console.print(
f"[bold red]Error:[/bold red] Failed to fully delete skill: {e}\n"
f"[yellow]Warning:[/yellow] Some files may have been partially removed.\n"
f"Please inspect: {skill_dir}/"
)
raise SystemExit(1) from e
if output_format == "json":
from deepagents_code.output import write_json
write_json(
"skills delete",
{
"name": skill_name,
"path": str(skill_dir),
"deleted": True,
},
)
return
checkmark = get_glyphs().checkmark
console.print(
f"{checkmark} Skill '{skill_name}' deleted successfully!",
style=theme.PRIMARY,View on GitHub (pinned to a1af029e6e)
Solutions
- Fix the underlying permission problem shown in the OSError message (chmod/chown the files or run with sufficient privileges)
- Close processes holding files open in the skill directory (editors, running agents)
- Manually remove whatever remains in the printed `skill_dir/` path
- Retry the delete after remounting writable if the volume was read-only
Example fix
// before $ dcode skills delete my-skill # Error: Failed to fully delete skill: [Errno 13] Permission denied ... // after $ chmod -R u+w ~/.deepagents/skills/my-skill $ rm -rf ~/.deepagents/skills/my-skill # or retry the CLI
Defensive patterns
Strategy: try-catch
Validate before calling
import os
def skill_dir_writable(skill_dir: Path) -> bool:
return os.access(skill_dir, os.W_OK | os.X_OK) and all(
os.access(p, os.W_OK) for p in skill_dir.rglob('*')
) Try / catch
import shutil
try:
shutil.rmtree(skill_dir)
except OSError as e:
print(f'partial delete possible, inspect {skill_dir}: {e}')
raise SystemExit(1) from e Prevention
- Check permissions on the skill tree before deleting
- Close editors/processes holding files in the directory open
- Avoid deleting skills on read-only or flaky network mounts
- Inspect the directory after a failed delete before retrying
When it happens
Trigger: `skills delete <name>` where `shutil.rmtree` fails midway: any `OSError` from unlinking files or removing directories inside `skill_dir` (EACCES, EROFS, EBUSY, ENOTEMPTY on odd filesystems).
Common situations: Deleting skills on read-only or network-mounted volumes; files owned by another user or locked by an editor/another agent process; filesystem bugs where rmtree partially completes before failing.
Related errors
- Error: Could not create project skills directory.
- debug log directory is not owned by the current user: {path}
- Cannot determine whether {str(left)!r} is {str(right)!r}: {e
- Invalid DEEPAGENTS_HOME {str(root)!r}: exists but cannot be
- Could not resolve {label} path {raw_path!r}: {exc}. Ensure t
AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29).
Data as JSON: /api/errors/2be7f44dc142d0b3.
Report an issue: GitHub.