Skip to content

fix(installer): ensure hooks/lib is copied with correct permissions (fixes #2185)#2188

Open
Yeachan-Heo wants to merge 1 commit intodevfrom
fix/issue-2185-copy-hooks-lib
Open

fix(installer): ensure hooks/lib is copied with correct permissions (fixes #2185)#2188
Yeachan-Heo wants to merge 1 commit intodevfrom
fix/issue-2185-copy-hooks-lib

Conversation

@Yeachan-Heo
Copy link
Copy Markdown
Owner

Summary

Fixes #2185: omc update was not copying templates/hooks/lib files with executable permissions, causing ERR_MODULE_NOT_FOUND errors when hooks tried to import stdin.mjs and atomic-write.mjs.

Root Cause

The ensureStandaloneHookScripts function in src/installer/index.ts had two redundant copy loops:

  1. First loop (lines 415-423): Copied lib files but did NOT set executable permissions
  2. Second loop (lines 431-439): Copied lib files WITH executable permissions (0o755)

Both loops targeted the same directories, so the first loop's unpermissioned copies would be overwritten by the second loop. However, if the first loop partially failed or if there were race conditions, files could end up without proper permissions.

Fix

Removed the redundant first loop that didn't set permissions. The second loop already handles all lib files correctly with proper permissions.

Changes

Testing

  • All 44 installer tests pass (including 2 new regression tests)
  • All 20 auto-update tests pass
  • Build completes successfully

Regression Tests Added

  1. should have all required lib files in templates/hooks/lib - Verifies stdin.mjs, atomic-write.mjs, config-dir.mjs exist
  2. should have all standalone hook template files present - Verifies all 7 main hook files exist

Closes #2185

…issions

The ensureStandaloneHookScripts function had two redundant loops that copied
files from templates/hooks/lib to ~/.claude/hooks/lib. The first loop did not
set executable permissions (0o755), which caused ERR_MODULE_NOT_FOUND errors
when hooks tried to import stdin.mjs and atomic-write.mjs after omc update.

Removed the redundant first loop, keeping only the second loop that properly
sets permissions with chmodSync(targetPath, 0o755).

Fixes #2185

Constraint: Both loops targeted the same source/destination directories
Constraint: Second loop already handled all required lib files with permissions
Rejected: Merge the loops - simpler to remove the redundant one entirely
Confidence: high
Scope-risk: narrow
Directive: Any future lib file copy operations must set executable permissions
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions github-actions bot added the size/S label Apr 5, 2026
@Yeachan-Heo
Copy link
Copy Markdown
Owner Author

Review note: diff scope looks narrow and targeted (installer loop cleanup + regression tests). Current CI failure is still the same repo-wide base red we saw on other PRs, not an installer-specific regression:

  • src/tests/hooks-command-escaping.test.ts
  • src/tests/pre-tool-enforcer.test.ts

Keeping this open while the base test failures are handled separately.


[repo owner's gaebal-gajae (clawdbot) 🦞]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant