{"record":{"id":"8c5de380fbba8d0c","repo":"oraios/serena","slug":"terraform-executable-not-found-please-ensure-terr","errorCode":null,"errorMessage":"Terraform executable not found, please ensure Terraform is installed.See https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli for instructions.","messagePattern":"Terraform executable not found, please ensure Terraform is installed\\.See https://developer\\.hashicorp\\.com/terraform/tutorials/aws-get-started/install-cli for instructions\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/solidlsp/language_servers/terraform_ls.py","lineNumber":115,"sourceCode":"            return\n\n        # TODO: is this needed?\n        # 2. Fallback to TERRAFORM_CLI_PATH (set by hashicorp/setup-terraform action)\n        if not terraform_cmd:\n            terraform_cli_path = os.environ.get(\"TERRAFORM_CLI_PATH\")\n            if terraform_cli_path:\n                log.debug(f\"Trying TERRAFORM_CLI_PATH: {terraform_cli_path}\")\n                # TODO: use binary name from runtime dependencies if we keep this code\n                if os.name == \"nt\":\n                    terraform_binary = os.path.join(terraform_cli_path, \"terraform.exe\")\n                else:\n                    terraform_binary = os.path.join(terraform_cli_path, \"terraform\")\n                if os.path.exists(terraform_binary):\n                    terraform_cmd = terraform_binary\n                    log.debug(f\"Found terraform via TERRAFORM_CLI_PATH: {terraform_cmd}\")\n                    return\n\n        raise RuntimeError(\n            \"Terraform executable not found, please ensure Terraform is installed.\"\n            \"See https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli for instructions.\"\n        )\n\n    @classmethod\n    def _setup_runtime_dependencies(cls, solidlsp_settings: SolidLSPSettings) -> str:\n        \"\"\"\n        Setup runtime dependencies for terraform-ls.\n        Downloads and installs terraform-ls if not already present.\n        \"\"\"\n        cls._ensure_tf_command_available()\n        terraform_settings = solidlsp_settings.get_ls_specific_settings(LanguageServerId.TERRAFORM)\n        terraform_ls_version = terraform_settings.get(\"terraform_ls_version\", DEFAULT_TERRAFORM_LS_VERSION)\n        platform_id = PlatformUtils.get_platform_id()\n        deps = RuntimeDependencyCollection(\n            [\n                RuntimeDependency(\n                    id=\"TerraformLS\",","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/solidlsp/language_servers/terraform_ls.py#L97-L133","documentation":"TerraformLS._ensure_tf_command_available verifies that a `terraform` binary is discoverable on PATH or via TERRAFORM_CLI_PATH before starting the server. If no executable is found anywhere it checks, it raises RuntimeError with a link to HashiCorp's install guide, because terraform-ls requires the Terraform CLI to operate.","triggerScenarios":"Calling SolidLanguageServer.create(\"terraform\") (or starting the server) via _setup_runtime_dependencies when `terraform` is not on PATH and TERRAFORM_CLI_PATH is unset or does not point to a directory containing a `terraform` binary.","commonSituations":"Fresh machines/CI containers without Terraform installed; TERRAFORM_CLI_PATH pointing to the binary instead of its containing directory; `terraform` installed only in a user dir not on PATH (e.g. via tfenv not linked); minimal Docker images.","solutions":["Install Terraform following https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli and ensure `terraform -version` works in the same shell.","Set TERRAFORM_CLI_PATH to the directory containing the `terraform` binary (e.g. /usr/local/bin), not the binary path itself.","In CI/Docker, install Terraform in the image or via a setup step (e.g. hashicorp/setup-terraform action) before running the language server."],"exampleFix":"// before\nTERRAFORM_CLI_PATH=/usr/local/bin/terraform  # points at the binary, not the dir\n// after\nexport TERRAFORM_CLI_PATH=/usr/local/bin  # dir containing `terraform`\n# or simply: export PATH=\"/usr/local/bin:$PATH\"","handlingStrategy":"validation","validationCode":"import shutil, os\nassert shutil.which(\"terraform\") or (\n    os.environ.get(\"TERRAFORM_CLI_PATH\")\n    and os.path.isfile(os.path.join(os.environ[\"TERRAFORM_CLI_PATH\"], \"terraform\"))\n), \"terraform must be on PATH or TERRAFORM_CLI_PATH must point to its directory\"","typeGuard":"def terraform_available() -> bool:\n    if shutil.which(\"terraform\"):\n        return True\n    p = os.environ.get(\"TERRAFORM_CLI_PATH\")\n    return bool(p) and os.path.isfile(os.path.join(p, \"terraform\"))","tryCatchPattern":"try:\n    server = SolidLanguageServer.create(\"terraform\")\nexcept RuntimeError as e:\n    if \"Terraform executable not found\" in str(e):\n        raise SystemExit(\"Install terraform: https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli\") from e\n    raise","preventionTips":["Install Terraform in dev images and CI containers as a setup step.","Set TERRAFORM_CLI_PATH to the directory containing the binary, not the binary itself.","Verify with `terraform -version` in the same environment that launches the language server."],"tags":["terraform","missing-executable","hcl","path","installation"],"backgroundTag":"language-server-binary-missing","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}