Spacelift.plan Not Found Error
Last updated: November 7, 2024
Issue: Spacelift.plan Not Found
Error Message: Error: Failed to read the given file as a state or plan file
This error typically occurs when the Spacelift plan file (Spacelift.plan) is not located in the expected directory after the planning phase, which can interrupt your run.
Possible Cause: Directory Change Before Plan Generation
One reason this error can occur is if a directory change happens before the planning phase, causing Spacelift.plan to be generated in the wrong location. By default, Spacelift expects Spacelift.plan to be in /mnt/workspace/source after the planning phase. If it is generated elsewhere, Spacelift cannot locate it, resulting in this error.
Troubleshooting Steps
Use an
after_planHook to MoveSpacelift.plan
If you need to change directories before planning, add anafter_planhook to ensureSpacelift.planis moved back to/mnt/workspace/sourceafter the planning phase.How to Set Up the
after_planHook:Go to your stack's hook tab.
Add an
after_planhook with a command to moveSpacelift.planto/mnt/workspace/source. For example:mv /path/to/generated/spacelift.plan /mnt/workspace/source/
Confirm Directory Location Using
after_applyHooks
If you’re not intentionally changing directories, you can set upafter_applyhooks to diagnose the issue. Using commands likels -laandpwdcan help verify whereSpacelift.planis being generated and identify if it’s in an unexpected directory.
Additional Troubleshooting Tips
Ensure that any custom scripts or hooks used before the planning phase do not unintentionally alter the directory structure.
Verify your stack’s configuration to check if directory changes are occurring automatically.
Need Further Assistance?
If the issue persists, please reach out to our support team with the following information:
Run ID
Relevant Hook Configurations
Any additional error messages or logs
Our team can provide guidance and help resolve any remaining issues with locating Spacelift.plan.