Skip to content

fix(cli): prevent infinite recursion when cloning default profile (#4…#4312

Closed
devorun wants to merge 1 commit into
NousResearch:mainfrom
devorun:patch-22
Closed

fix(cli): prevent infinite recursion when cloning default profile (#4…#4312
devorun wants to merge 1 commit into
NousResearch:mainfrom
devorun:patch-22

Conversation

@devorun

@devorun devorun commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

…306)

What does this PR do?

Fixes #4306

The Issue:
When using hermes profile create <name> --clone-all, the CLI copies the active profile to the new destination. However, when cloning from the default root (~/.hermes), shutil.copytree would recursively copy the profiles/ directory into the newly created profile (~/.hermes/profiles/<name>), leading to an infinite nesting loop that consumed all available disk space and eventually crashed with a PATH_MAX error.

The Fix:
Added ignore=shutil.ignore_patterns("profiles", "gateway.pid") to the shutil.copytree call. This explicitly prevents the clone operation from diving into the profiles subdirectory, entirely avoiding the infinite recursion. As an added safety measure, gateway.pid is also ignored to prevent stale PID locks from being copied over to the new profile.

Related Issue

Fixes #

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

How to Test

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform:

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

For New Skills

  • This skill is broadly useful to most users (if bundled) — see Contributing Guide
  • SKILL.md follows the standard format (frontmatter, trigger conditions, steps, pitfalls)
  • No external dependencies that aren't already available (prefer stdlib, curl, existing Hermes tools)
  • I've tested the skill end-to-end: hermes --toolsets skills -q "Use the X skill to do Y"

Screenshots / Logs

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard labels May 2, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Note: Competing fixes for #4306 exist at #6163 (destination-inside-source detection) and #11829 (symlinks=True). Maintainers should pick the most robust approach.

@alt-glitch

Copy link
Copy Markdown
Collaborator

Note: Competing fixes for #4306 exist at #6163 and #11829. Maintainers should pick the most robust approach.

@teknium1

Copy link
Copy Markdown
Contributor

Closing as already fixed on main.

Triage notes (high confidence):
hermes_cli/profiles.py:707-710 on main already uses _clone_all_copytree_ignore with _CLONE_ALL_DEFAULT_EXCLUDE_ROOT={'profiles', ...} to prevent the recursive default-profile copy.

If you still see this on the latest version, please reopen with reproduction steps.

(Bulk-closed during a CLI triage sweep.)

@teknium1 teknium1 closed this May 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: --clone-all flag creates an infinitely recursive duplicate w/in the profiles directory, takes up all available disk space.

3 participants