fix(cli): symlink CLI binaries into /usr/local/bin for non-interactive hooks - #456
Conversation
|
Checked manually, and tests pass The fix: save-and-restore pattern Current code (lines 105–107): Fixed code: Why this is safer: If symlinkSync(source, target) fails (e.g., a momentary permissions race), the inner catch immediately puts the original symlink back. The outer catch at line 108 still fires (because createErr is re-thrown), so the manual sudo ln -sf ... hint is still printed. The user ends up with their old, working symlink intact rather than nothing. The temp+rename alternative would be fully atomic (no window where the path is absent), but requires fs.renameSync and a temp filename, which is more code. For a postinstall script the save-and-restore pattern is the simpler, proportionate fix. |
…e hooks SessionStart/SessionEnd hooks run `codemie hook` in a plain non-interactive, non-login `/usr/bin/bash -c "..."` subshell that never sources ~/.zshrc or ~/.bashrc, so the rc-file PATH patch postinstall.mjs relied on never took effect there even though the user's own terminal worked fine. postinstall.mjs now also symlinks every CLI bin (from package.json's `bin` field) into /usr/local/bin, which every shell has on PATH regardless of interactivity. Falls back to a printed manual `sudo ln -sf` hint when that directory isn't writable, and skips existing non-symlink files instead of clobbering them. Existing rc-file behavior is unchanged. Ref: INC0000799603 / UR0002016875
9dfbdfc to
a927699
Compare
Summary
SessionStart/SessionEndhooks runcodemie hookinside a plain non-interactive, non-login/usr/bin/bash -c "..."subshell, which never sources~/.zshrc/~/.bashrc.postinstall.mjsonly patched PATH via those rc files, so the hook failed withcodemie: command not foundeven on a healthy install (codemie doctorgreen,codemie-claudeworking) — and reinstalling didn't help, since the binary was already correctly installed and linked.Changes
scripts/postinstall.mjs: in addition to the existing rc-file PATH patch, symlink every CLI bin (read frompackage.json'sbinfield) into/usr/local/bin, which is on PATH for every shell regardless of interactivity/login status.win32./usr/local/bindoesn't exist or isn't writable, prints the exactsudo ln -sf ...command(s) needed as a self-service manual fix — no reinstall required.codemie doctor,codemie-claude) is unchanged.Testing
node --check scripts/postinstall.mjs,npm run typecheck,npm run buildall pass; pre-commit hooks (lint-staged, typecheck, gitleaks) passed on commit.Checklist
npm run ci)mainRef: EPMCDME-13884, INC0000799603 / UR0002016875