"Required Plugins Are Not Installed" Error
Last updated: November 7, 2024
Issue: Required Plugins Are Not Installed
Error Message: Error: Required plugins are not installed
This error occurs when a Spacelift run in the applying state cannot locate the necessary plugins or providers. This guide outlines the common causes and solutions to address this issue effectively.
Background
In Spacelift, a run in the applying state can be handled by a different worker than the one that managed the planning phase. Since Spacelift does not automatically initialize plugins during the apply phase, the worker running the apply may not have the necessary plugins if it wasn’t the same worker that ran the plan.
To preserve the consistency of the plan, Spacelift saves a copy of the workspace, including the .terraform folder (but not the plugins), to S3 between the plan and apply stages. This ensures that the apply phase uses the exact output of the planning phase.
Troubleshooting Steps
Use a Pre-Apply Hook to Re-Initialize Providers
Adding a pre-apply hook to re-runterraform initwill ensure the required providers are available before the apply phase begins.Example Pre-Apply Hook:
terraform init -lockfile=readonlyThis command ensures that the providers are re-downloaded as needed without modifying the lockfile. Alternatively, using
terraform init -upgrademay also be beneficial, as it forces a re-download of plugins, which can resolve version or compatibility issues.Check Architecture Consistency
Ensure that all workers in the pool have the same architecture, as mismatched architectures can prevent plugins from being compatible across different workers.For Kubernetes users, you can specify architecture using the
kubernetes.io/archselector label to ensure that your workers match. This is especially important if you’re using a mix of ARM and x86 architectures.Verify
.terraformrcand Extra Mount ConfigurationsCustom
.terraformrc: If you’re using a custom.terraformrcfile to manage provider settings or caching, check that it is properly configured.Extra Mounts for TF Plugins: For users configuring
SPACELIFT_WORKER_EXTRA_MOUNTSto mount Terraform plugins, ensure that these mounts are set up correctly.
You can do any mounts outside of the Spacelift-managed directory and use
before/afterhooks to move files into the cache as needed for both plan and apply phases.
Additional Considerations
When does this happen?
Runs may be handled by different workers if:
Autodeploy is disabled on your stack, requiring a manual confirmation step.
A plan policy produces a warning that requires attention before proceeding.
An approval policy is in place, requiring approval before the apply stage can proceed.
In each of these scenarios, a different worker may pick up the run, potentially leading to plugin issues if the plugins haven’t been initialized on the new worker.
Need Assistance?
If the above steps do not resolve your issue, please reach out to Spacelift Support with the following information:
Run ID or Stack Name
Any hook configurations related to plugin initialization
Custom
.terraformrcsettings or extra mount configurations
Our team can help to analyze and resolve plugin-related issues specific to your Spacelift setup.