Root Cause: npm install -g @z_ai/coding-helper was failing with EACCES
(permission denied) when trying to create /usr/local/lib/node_modules/@z_ai,
but the error was being suppressed by 2>/dev/null in the original version.
The script would report "Installation completed" even though it failed.
Solution: Enhanced error handling with three paths:
1. Success Path (exit code = 0):
- Verify installation with 'npm list -g'
- Show "installed and verified!" message
- Offer to launch wizard
2. Permission Error Path (EACCES detected):
- Clear error message explaining the permission issue
- Show 3 options:
a) Use sudo (with interactive retry)
b) Fix npm permissions permanently (chown command)
c) Run without installation using npx
- Interactive prompt to try sudo immediately
3. Other Error Path:
- Show full error output
- Suggest manual installation with sudo
- Remind that npx works without installation
Changes:
- install_coding_helper(): Added EACCES detection, sudo retry option,
and clear error messages for all failure scenarios
- Error output is now captured and displayed for debugging
- Added verification step after sudo installation
The script now properly handles the common case where users don't have
write permissions to /usr/local/lib/node_modules and offers multiple
solutions including an interactive sudo retry.
Co-Authored-By: Claude <noreply@anthropic.com>
36 KiB
Executable File
36 KiB
Executable File