Skip to content

Fix RAG CLI plugin marketplace cache error#2

Merged
ItMeDiaTech merged 1 commit intomasterfrom
claude/fix-rag-cli-marketplace-cache-011CUzRt6mA1s4VQF1x1H4UT
Nov 10, 2025
Merged

Fix RAG CLI plugin marketplace cache error#2
ItMeDiaTech merged 1 commit intomasterfrom
claude/fix-rag-cli-marketplace-cache-011CUzRt6mA1s4VQF1x1H4UT

Conversation

@ItMeDiaTech
Copy link
Owner

Resolves EPERM permission denied errors during marketplace cache finalization on Windows by preventing file handle locks from lifecycle hooks.

Root Cause:

  • Lifecycle hooks imported modules that initialized PathResolver singleton
  • PathResolver checked marketplace cache directory and held file references
  • Python kept file handles open after hook completed
  • Windows prevented marketplace directory rename due to open handles

Changes:

  1. Skip marketplace during lifecycle hooks (path_resolver.py, path_utils.py)

    • Added CLAUDE_LIFECYCLE_HOOK environment variable check
    • Skip marketplace directory when variable is "true"
    • Prevents PathResolver from locking marketplace cache
  2. Set environment variable in lifecycle config (lifecycle.json)

    • All hooks (post_install, pre_update, post_update) set CLAUDE_LIFECYCLE_HOOK=true
    • Signals to path resolution to avoid marketplace cache
  3. Remove module imports from verification (installer.py)

    • Removed imports that triggered PathResolver initialization
    • Verification now only checks directory structure
    • Module imports verified at runtime instead of install time
  4. Explicit resource cleanup (installer.py, updater.py)

    • Added cleanup_resources() function to both modules
    • Forces garbage collection to release file handles
    • Clears PathResolver singleton instances
    • Runs in finally block to ensure execution
  5. Added CLAUDE_PLUGIN_ROOT support (path_resolver.py)

    • PathResolver now checks CLAUDE_PLUGIN_ROOT environment variable
    • Ensures hooks use installation directory, not marketplace cache

Impact:

  • Marketplace installation now completes without permission errors
  • No warnings about "Failed to finalize marketplace cache"
  • All functionality preserved

Files Modified:

  • .claude-plugin/lifecycle.json
  • src/rag_cli_plugin/lifecycle/installer.py
  • src/rag_cli_plugin/lifecycle/updater.py
  • src/rag_cli/core/path_resolver.py
  • src/rag_cli_plugin/hooks/path_utils.py
  • KNOWN_ISSUES.md (comprehensive documentation)

Tested on: Windows path handling scenarios
Platform: Primarily affects Windows (stricter file locking)

Resolves EPERM permission denied errors during marketplace cache finalization
on Windows by preventing file handle locks from lifecycle hooks.

Root Cause:
- Lifecycle hooks imported modules that initialized PathResolver singleton
- PathResolver checked marketplace cache directory and held file references
- Python kept file handles open after hook completed
- Windows prevented marketplace directory rename due to open handles

Changes:

1. Skip marketplace during lifecycle hooks (path_resolver.py, path_utils.py)
   - Added CLAUDE_LIFECYCLE_HOOK environment variable check
   - Skip marketplace directory when variable is "true"
   - Prevents PathResolver from locking marketplace cache

2. Set environment variable in lifecycle config (lifecycle.json)
   - All hooks (post_install, pre_update, post_update) set CLAUDE_LIFECYCLE_HOOK=true
   - Signals to path resolution to avoid marketplace cache

3. Remove module imports from verification (installer.py)
   - Removed imports that triggered PathResolver initialization
   - Verification now only checks directory structure
   - Module imports verified at runtime instead of install time

4. Explicit resource cleanup (installer.py, updater.py)
   - Added cleanup_resources() function to both modules
   - Forces garbage collection to release file handles
   - Clears PathResolver singleton instances
   - Runs in finally block to ensure execution

5. Added CLAUDE_PLUGIN_ROOT support (path_resolver.py)
   - PathResolver now checks CLAUDE_PLUGIN_ROOT environment variable
   - Ensures hooks use installation directory, not marketplace cache

Impact:
- Marketplace installation now completes without permission errors
- No warnings about "Failed to finalize marketplace cache"
- All functionality preserved

Files Modified:
- .claude-plugin/lifecycle.json
- src/rag_cli_plugin/lifecycle/installer.py
- src/rag_cli_plugin/lifecycle/updater.py
- src/rag_cli/core/path_resolver.py
- src/rag_cli_plugin/hooks/path_utils.py
- KNOWN_ISSUES.md (comprehensive documentation)

Tested on: Windows path handling scenarios
Platform: Primarily affects Windows (stricter file locking)
@ItMeDiaTech ItMeDiaTech merged commit 9150749 into master Nov 10, 2025
1 check failed
@ItMeDiaTech ItMeDiaTech deleted the claude/fix-rag-cli-marketplace-cache-011CUzRt6mA1s4VQF1x1H4UT branch November 10, 2025 16:48
ItMeDiaTech pushed a commit that referenced this pull request Nov 11, 2025
Critical fixes for v2.0:

Configuration:
- Disable PostToolUse hook in hooks.json (known Claude Code framework bug)
- Add "enabled": false flag and update description

Code cleanup:
- Remove semantic_cache_hnsw.py (imports non-existent faiss dependency)
- Remove vector_store.py.faiss_backup (migration artifact)
- Update semantic_cache.py docstring to reference ChromaDB

Documentation:
- Replace all FAISS references with ChromaDB throughout README.md
- Update import examples to v2.0 structure (from rag_cli.core import X)
- Improve project status messaging (remove "Sorta WORKING" language)
- Fix ChromaDB debugging example in CLAUDE.md
- Correct documentation links (ChromaDB docs instead of FAISS wiki)

Impact:
- Prevents runtime errors from missing FAISS dependency
- Aligns documentation with actual implementation (ChromaDB)
- Fixes PostToolUse hook configuration per KNOWN_ISSUES.md
- Provides professional messaging for production v2.0.0 release

Resolves issues identified in error analysis:
- Issue #1: PostToolUse hook configuration mismatch
- Issue #2: Missing FAISS dependency in semantic_cache_hnsw.py
- Issue #3: Outdated import examples in README
- Issue #4: README extensively references FAISS instead of ChromaDB
- Issue #5: Leftover migration backup file
- Issue #6: Unprofessional project status messaging
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants