Troubleshooting "Unexpected exit code 1" errors during workspace initialization
Last updated: August 20, 2025
If you're encountering an "Unexpected exit code when initializing workspace: 1" error with minimal details in your stack logs, this typically indicates that one of your custom hooks is failing during the workspace initialization process.
Identifying the failing hook
When you have multiple custom hooks configured for your workspace, the easiest way to troubleshoot this issue is to isolate which specific hook is causing the failure:
Add echo statements between your hooks to create checkpoints in your initialization process
Run your stack again and check the logs to see where the process stops
The hook that runs after the last successful echo statement is likely the one causing the issue
Debugging the specific hook
Once you've identified the failing hook:
Focus your debugging efforts on that specific script
Check for common issues like:
Missing dependencies or binaries
Incorrect file paths
Permission issues
Syntax errors in the hook script
Add additional logging within the hook itself to get more detailed error information
This systematic approach will help you quickly identify and resolve the root cause of the initialization failure.