terraform: lsp server can't find files
Thank you for the bug report
- [X] I am using the latest version of
lsp-moderelated packages. - [X] I checked FAQ and Troubleshooting sections
- [ ] You may also try reproduce the issue using clean environment using the following command:
M-x lsp-start-plain
Bug description
After starting to edit a Terraform file the LSP server starts sending errors like rpc_logger.go:45: Error for "textDocument/documentLink" (ID 19): [-32098] main.tf: file not found.
The LSP server starts fine initially it's only after making changes to the file that the errors start. After the errors start the server doesn't seem to be able to find the file again and the LSP features stop working.
I have a feeling this is my configuration error but I'm a bit out of my depth here.
This is on Emacs 28.1 and lsp-mode-20220907.1223.
Steps to reproduce
- Open a Terraform file
- Make some changes
I have lsp-mode setup with use-package as follows:
(use-package lsp-mode
:ensure t
:init (setq lsp-keymap-prefix "C-c l")
:config
(setq lsp-prefer-flymake :none)
(lsp-register-custom-settings
'(("pyls.plugins.pyls_black.enabled" t t)
("pyls.plugins.pyls_isort.enabled" t t)
;; Disable these as they're duplicated by flake8
("pyls.plugins.pycodestyle.enabled" nil t)
("pyls.plugins.mccabe.enabled" nil t)
("pyls.plugins.pyflakes.enabled" nil t)))
(setq lsp-log-io t)
:hook ((go-mode . lsp)
(terraform-mode . lsp-deferred)
(yaml-mode . lsp)
(lsp-mode . lsp-enable-which-key-integration)
(python-mode . lsp))
:commands (lsp lsp-deferred))
Expected behavior
The expected behavior is that the LSP server finds the file and provides LSP features.
Which Language Server did you use?
terraform-ls from Homebrew.
❯ terraform-ls version
0.29.1-Homebrew
platform: darwin/amd64
go: go1.19
compiler: gc
OS
MacOS
Error callstack
## lsp-log
Command "terraform-lsp" is not present on the path.
Command "terraform-ls serve" is present on the path.
Command "terraform-lsp" is not present on the path.
Command "terraform-ls serve" is present on the path.
Found the following clients for /Users/sopalenski/dev/terraform_scratch/main.tf: (server-id tfmls, priority 1)
The following clients were selected based on priority: (server-id tfmls, priority 1)
Creating watchers for following 10 folders:
/Users/sopalenski/dev/terraform_scratch
/Users/sopalenski/dev/terraform_scratch/.terraform
/Users/sopalenski/dev/terraform_scratch/.terraform/providers
/Users/sopalenski/dev/terraform_scratch/.terraform/providers/registry.terraform.io
/Users/sopalenski/dev/terraform_scratch/.terraform/providers/registry.terraform.io/hashicorp
/Users/sopalenski/dev/terraform_scratch/.terraform/providers/registry.terraform.io/hashicorp/aws
/Users/sopalenski/dev/terraform_scratch/.terraform/providers/registry.terraform.io/hashicorp/aws/3.25.0
/Users/sopalenski/dev/terraform_scratch/.terraform/providers/registry.terraform.io/hashicorp/aws/3.25.0/darwin_amd64
/Users/sopalenski/dev/terraform_scratch/.terraform/providers/registry.terraform.io/hashicorp/aws/3.63.0
/Users/sopalenski/dev/terraform_scratch/.terraform/providers/registry.terraform.io/hashicorp/aws/3.63.0/darwin_amd64
## lsp-workspace-show-log
[Trace - 12:14:01 PM] Sending request 'initialize - (1)'.
Params: {
"processId": null,
"rootPath": "/Users/sopalenski/dev/terraform_scratch",
"clientInfo": {
"name": "emacs",
"version": "GNU Emacs 28.1 (build 2, x86_64-apple-darwin21.4.0, NS appkit-2113.40 Version 12.3.1 (Build 21E258))\n of 2022-05-31"
},
"rootUri": "file:///Users/sopalenski/dev/terraform_scratch",
"capabilities": {
"workspace": {
"workspaceEdit": {
"documentChanges": true,
"resourceOperations": [
"create",
"rename",
"delete"
]
},
"applyEdit": true,
"symbol": {
"symbolKind": {
"valueSet": [
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26
]
}
},
"executeCommand": {
"dynamicRegistration": false
},
"didChangeWatchedFiles": {
"dynamicRegistration": true
},
"workspaceFolders": true,
"configuration": true,
"codeLens": {
"refreshSupport": true
},
"fileOperations": {
"didCreate": false,
"willCreate": false,
"didRename": true,
"willRename": true,
"didDelete": false,
"willDelete": false
}
},
"textDocument": {
"declaration": {
"dynamicRegistration": true,
"linkSupport": true
},
"definition": {
"dynamicRegistration": true,
"linkSupport": true
},
"implementation": {
"dynamicRegistration": true,
"linkSupport": true
},
"typeDefinition": {
"dynamicRegistration": true,
"linkSupport": true
},
"synchronization": {
"willSave": true,
"didSave": true,
"willSaveWaitUntil": true
},
"documentSymbol": {
"symbolKind": {
"valueSet": [
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26
]
},
"hierarchicalDocumentSymbolSupport": true
},
"formatting": {
"dynamicRegistration": true
},
"rangeFormatting": {
"dynamicRegistration": true
},
"onTypeFormatting": {
"dynamicRegistration": true
},
"rename": {
"dynamicRegistration": true,
"prepareSupport": true
},
"codeAction": {
"dynamicRegistration": true,
"isPreferredSupport": true,
"codeActionLiteralSupport": {
"codeActionKind": {
"valueSet": [
"",
"quickfix",
"refactor",
"refactor.extract",
"refactor.inline",
"refactor.rewrite",
"source",
"source.organizeImports"
]
}
},
"resolveSupport": {
"properties": [
"edit",
"command"
]
},
"dataSupport": true
},
"completion": {
"completionItem": {
"snippetSupport": true,
"documentationFormat": [
"markdown",
"plaintext"
],
"resolveAdditionalTextEditsSupport": true,
"insertReplaceSupport": true,
"deprecatedSupport": true,
"resolveSupport": {
"properties": [
"documentation",
"detail",
"additionalTextEdits",
"command"
]
},
"insertTextModeSupport": {
"valueSet": [
1,
2
]
}
},
"contextSupport": true,
"dynamicRegistration": true
},
"signatureHelp": {
"signatureInformation": {
"parameterInformation": {
"labelOffsetSupport": true
}
},
"dynamicRegistration": true
},
"documentLink": {
"dynamicRegistration": true,
"tooltipSupport": true
},
"hover": {
"contentFormat": [
"markdown",
"plaintext"
],
"dynamicRegistration": true
},
"foldingRange": {
"dynamicRegistration": true
},
"selectionRange": {
"dynamicRegistration": true
},
"callHierarchy": {
"dynamicRegistration": false
},
"typeHierarchy": {
"dynamicRegistration": true
},
"publishDiagnostics": {
"relatedInformation": true,
"tagSupport": {
"valueSet": [
1,
2
]
},
"versionSupport": true
},
"linkedEditingRange": {
"dynamicRegistration": true
}
},
"window": {
"workDoneProgress": true,
"showDocument": {
"support": true
}
}
},
"initializationOptions": null,
"workDoneToken": "1"
}
[Trace - 12:14:01 PM] Received response 'initialize - (1)' in 169ms.
Result: {
"capabilities": {
"textDocumentSync": {
"openClose": true,
"change": 2,
"save": {}
},
"completionProvider": {
"triggerCharacters": [
".",
"["
],
"resolveProvider": true,
"completionItem": {}
},
"hoverProvider": true,
"signatureHelpProvider": {},
"declarationProvider": {},
"definitionProvider": true,
"referencesProvider": true,
"documentSymbolProvider": true,
"codeActionProvider": {
"codeActionKinds": [
"source.formatAll.terraform"
]
},
"codeLensProvider": {},
"documentLinkProvider": {},
"workspaceSymbolProvider": true,
"documentFormattingProvider": true,
"documentOnTypeFormattingProvider": {
"firstTriggerCharacter": ""
},
"executeCommandProvider": {
"commands": [
"terraform-ls.module.callers",
"terraform-ls.module.calls",
"terraform-ls.module.providers",
"terraform-ls.module.terraform",
"terraform-ls.rootmodules",
"terraform-ls.terraform.init",
"terraform-ls.terraform.validate"
],
"workDoneProgress": true
},
"semanticTokensProvider": {
"legend": {
"tokenTypes": [],
"tokenModifiers": []
},
"full": null
},
"workspace": {
"workspaceFolders": {
"supported": true,
"changeNotifications": "workspace/didChangeWorkspaceFolders"
}
},
"experimental": {
"referenceCountCodeLens": null,
"refreshModuleProviders": null,
"refreshModuleCalls": null,
"refreshTerraformVersion": null
}
},
"serverInfo": {
"name": "terraform-ls",
"version": "0.29.1-Homebrew"
}
}
[Trace - 12:14:01 PM] Sending notification 'initialized'.
Params: {}
[Trace - 12:14:01 PM] Sending notification 'textDocument/didOpen'.
Params: {
"textDocument": {
"uri": "file:///Users/sopalenski/dev/terraform_scratch/main.tf",
"languageId": "terraform",
"version": 0,
"text": "provider \"aws\" {\n region = \"us-east-1\"\n}\n\ndata \"aws_subnet\" \"galcapp_mgmt\" {\n id = \"subnet-0d7cf1345bb5add54\"\n}\n\ndata \"aws_security_group\" \"mgmt_sg\" {\n id = \"sg-0f548d25b5df4479b\"\n}\n\n# \"ami-06ddef68828e3b2c8\" is the app-tools ami with a fixed datadog.\n# called galcapp-app-tools-dev_2021-jan-26_8bc678c\n\n# ami-0039d5312a80d6479 is the app packager with fixed datadog.\n# called galcapp-jenkins-agent-app-packages_dev_2021-jan-27_9bb07dd\n\n# ami-0ada78ca862f817ad is the image factory with fixed datadog.\n# called galcapp-jenkins-agent-image-factory_dev_2021-jan-27_9bb07dd\n\n# ami-0810a504f6c213caf is the image factory with a fixed fixed datadog\n# called galcapp-jenkins-agent-image-factory_dev_2021-jan-27_9bb07dd\n\nresource \"aws_instance\" \"scratch\" {\n ami = \"ami-05874fa9befd5c838\"\n subnet_id = data.aws_subnet.galcapp_mgmt.id\n iam_instance_profile = \"AmazonSSMRoleForInstancesQuickSetup\"\n instance_type = \"t3.micro\"\n key_name = \"devops_demo_key\"\n security_groups = [data.aws_security_group.mgmt_sg.id]\n tags = {\n Name = \"FEZ-1137-alert-logic-role\"\n ab_deploy_method = \"terraform\"\n ab_deploy_owner = \"sopalenski\"\n ab_deploy_env = \"dev\"\n }\n}\n\noutput \"instance_id\" {\n value = aws_instance.scratch.id\n}\n\n"
}
}
[Trace - 12:14:01 PM] Sending request 'textDocument/documentSymbol - (2)'.
Params: {
"textDocument": {
"uri": "file:///Users/sopalenski/dev/terraform_scratch/main.tf"
}
}
[Trace - 12:14:01 PM] Sending request 'textDocument/codeLens - (3)'.
Params: {
"textDocument": {
"uri": "file:///Users/sopalenski/dev/terraform_scratch/main.tf"
}
}
[Trace - 12:14:01 PM] Sending notification '$/cancelRequest'.
Params: {
"id": 2
}
[Trace - 12:14:01 PM] Sending request 'textDocument/documentSymbol - (4)'.
Params: {
"textDocument": {
"uri": "file:///Users/sopalenski/dev/terraform_scratch/main.tf"
}
}
[Trace - 12:14:01 PM] Sending request 'textDocument/codeAction - (5)'.
Params: {
"textDocument": {
"uri": "file:///Users/sopalenski/dev/terraform_scratch/main.tf"
},
"range": {
"start": {
"line": 0,
"character": 0
},
"end": {
"line": 0,
"character": 0
}
},
"context": {
"diagnostics": []
}
}
[Trace - 12:14:01 PM] Sending request 'textDocument/documentLink - (6)'.
Params: {
"textDocument": {
"uri": "file:///Users/sopalenski/dev/terraform_scratch/main.tf"
}
}
[Trace - 12:14:01 PM] Sending notification '$/cancelRequest'.
Params: {
"id": 3
}
[Trace - 12:14:01 PM] Sending request 'textDocument/codeLens - (7)'.
Params: {
"textDocument": {
"uri": "file:///Users/sopalenski/dev/terraform_scratch/main.tf"
}
}
[Trace - 12:14:01 PM] Sending notification '$/cancelRequest'.
Params: {
"id": 4
}
[Trace - 12:14:01 PM] Sending request 'textDocument/documentSymbol - (8)'.
Params: {
"textDocument": {
"uri": "file:///Users/sopalenski/dev/terraform_scratch/main.tf"
}
}
[Trace - 12:14:01 PM] Sending notification '$/cancelRequest'.
Params: {
"id": 7
}
[Trace - 12:14:01 PM] Sending request 'textDocument/codeLens - (9)'.
Params: {
"textDocument": {
"uri": "file:///Users/sopalenski/dev/terraform_scratch/main.tf"
}
}
[Trace - 12:14:01 PM] Received request 'client/registerCapability - (1).
Params: {
"registrations": [
{
"id": "fa0cbeb5-5346-2065-b6df-56f40b049858",
"method": "workspace/didChangeWatchedFiles",
"registerOptions": {
"watchers": [
{
"globPattern": "**/.terraform",
"kind": 3
},
{
"globPattern": "**/.terraform/modules/modules.json"
},
{
"globPattern": "**/.terraform.lock.hcl"
},
{
"globPattern": "**/.terraform/plugins/selections.json"
},
{
"globPattern": "**/.terraform/plugins/darwin_amd64/lock.json"
}
]
}
}
]
}
[Trace - 12:14:01 PM] Sending response 'client/registerCapability - (1)'. Processing request took 7ms
Params: {
"jsonrpc": "2.0",
"id": 1,
"result": null
}
[Trace - 12:14:02 PM] Sending notification '$/cancelRequest'.
Params: {
"id": 8
}
[Trace - 12:14:02 PM] Sending request 'textDocument/documentSymbol - (10)'.
Params: {
"textDocument": {
"uri": "file:///Users/sopalenski/dev/terraform_scratch/main.tf"
}
}
[Trace - 12:14:02 PM] Sending notification '$/cancelRequest'.
Params: {
"id": 5
}
[Trace - 12:14:02 PM] Sending request 'textDocument/codeAction - (11)'.
Params: {
"textDocument": {
"uri": "file:///Users/sopalenski/dev/terraform_scratch/main.tf"
},
"range": {
"start": {
"line": 0,
"character": 0
},
"end": {
"line": 0,
"character": 0
}
},
"context": {
"diagnostics": []
}
}
[Trace - 12:14:02 PM] Sending request 'textDocument/documentLink - (12)'.
Params: {
"textDocument": {
"uri": "file:///Users/sopalenski/dev/terraform_scratch/main.tf"
}
}
[Trace - 12:14:03 PM] Received response 'nil - (5)' in 0ms.
Result: null
[Trace - 12:14:03 PM] Received response 'nil - (3)' in 0ms.
Result: {
"code": -32800,
"message": "error code -32800: %!s(<nil>)"
}
[Trace - 12:14:03 PM] Received response 'nil - (4)' in 0ms.
Result: [
{
"name": "provider \"aws\"",
"kind": 5,
"range": {
"start": {
"line": 0,
"character": 0
},
"end": {
"line": 2,
"character": 1
}
},
"selectionRange": {
"start": {
"line": 0,
"character": 0
},
"end": {
"line": 2,
"character": 1
}
},
"children": [
{
"name": "region",
"kind": 15,
"range": {
"start": {
"line": 1,
"character": 2
},
"end": {
"line": 1,
"character": 22
}
},
"selectionRange": {
"start": {
"line": 1,
"character": 2
},
"end": {
"line": 1,
"character": 22
}
}
}
]
},
{
"name": "data \"aws_subnet\" \"galcapp_mgmt\"",
"kind": 5,
"range": {
"start": {
"line": 4,
"character": 0
},
"end": {
"line": 6,
"character": 1
}
},
"selectionRange": {
"start": {
"line": 4,
"character": 0
},
"end": {
"line": 6,
"character": 1
}
},
"children": [
{
"name": "id",
"kind": 15,
"range": {
"start": {
"line": 5,
"character": 2
},
"end": {
"line": 5,
"character": 33
}
},
"selectionRange": {
"start": {
"line": 5,
"character": 2
},
"end": {
"line": 5,
"character": 33
}
}
}
]
},
{
"name": "data \"aws_security_group\" \"mgmt_sg\"",
"kind": 5,
"range": {
"start": {
"line": 8,
"character": 0
},
"end": {
"line": 10,
"character": 1
}
},
"selectionRange": {
"start": {
"line": 8,
"character": 0
},
"end": {
"line": 10,
"character": 1
}
},
"children": [
{
"name": "id",
"kind": 15,
"range": {
"start": {
"line": 9,
"character": 2
},
"end": {
"line": 9,
"character": 29
}
},
"selectionRange": {
"start": {
"line": 9,
"character": 2
},
"end": {
"line": 9,
"character": 29
}
}
}
]
},
{
"name": "resource \"aws_instance\" \"scratch\"",
"kind": 5,
"range": {
"start": {
"line": 24,
"character": 0
},
"end": {
"line": 37,
"character": 1
}
},
"selectionRange": {
"start": {
"line": 24,
"character": 0
},
"end": {
"line": 37,
"character": 1
}
},
"children": [
{
"name": "ami",
"kind": 15,
"range": {
"start": {
"line": 25,
"character": 2
},
"end": {
"line": 25,
"character": 48
}
},
"selectionRange": {
"start": {
"line": 25,
"character": 2
},
"end": {
"line": 25,
"character": 48
}
}
},
{
"name": "subnet_id",
"kind": 14,
"range": {
"start": {
"line": 26,
"character": 2
},
"end": {
"line": 26,
"character": 56
}
},
"selectionRange": {
"start": {
"line": 26,
"character": 2
},
"end": {
"line": 26,
"character": 56
}
}
},
{
"name": "iam_instance_profile",
"kind": 15,
"range": {
"start": {
"line": 27,
"character": 2
},
"end": {
"line": 27,
"character": 62
}
},
"selectionRange": {
"start": {
"line": 27,
"character": 2
},
"end": {
"line": 27,
"character": 62
}
}
},
{
"name": "instance_type",
"kind": 15,
"range": {
"start": {
"line": 28,
"character": 2
},
"end": {
"line": 28,
"character": 35
}
},
"selectionRange": {
"start": {
"line": 28,
"character": 2
},
"end": {
"line": 28,
"character": 35
}
}
},
{
"name": "key_name",
"kind": 15,
"range": {
"start": {
"line": 29,
"character": 2
},
"end": {
"line": 29,
"character": 42
}
},
"selectionRange": {
"start": {
"line": 29,
"character": 2
},
"end": {
"line": 29,
"character": 42
}
}
},
{
"name": "security_groups",
"kind": 18,
"range": {
"start": {
"line": 30,
"character": 2
},
"end": {
"line": 30,
"character": 61
}
},
"selectionRange": {
"start": {
"line": 30,
"character": 2
},
"end": {
"line": 30,
"character": 61
}
},
"children": [
{
"name": "0",
"kind": 14,
"range": {
"start": {
"line": 30,
"character": 26
},
"end": {
"line": 30,
"character": 60
}
},
"selectionRange": {
"start": {
"line": 30,
"character": 26
},
"end": {
"line": 30,
"character": 60
}
}
}
]
},
{
"name": "tags",
"kind": 23,
"range": {
"start": {
"line": 31,
"character": 2
},
"end": {
"line": 36,
"character": 3
}
},
"selectionRange": {
"start": {
"line": 31,
"character": 2
},
"end": {
"line": 36,
"character": 3
}
},
"children": [
{
"name": "Name",
"kind": 15,
"range": {
"start": {
"line": 32,
"character": 4
},
"end": {
"line": 32,
"character": 50
}
},
"selectionRange": {
"start": {
"line": 32,
"character": 4
},
"end": {
"line": 32,
"character": 50
}
}
},
{
"name": "ab_deploy_method",
"kind": 15,
"range": {
"start": {
"line": 33,
"character": 4
},
"end": {
"line": 33,
"character": 34
}
},
"selectionRange": {
"start": {
"line": 33,
"character": 4
},
"end": {
"line": 33,
"character": 34
}
}
},
{
"name": "ab_deploy_owner",
"kind": 15,
"range": {
"start": {
"line": 34,
"character": 4
},
"end": {
"line": 34,
"character": 35
}
},
"selectionRange": {
"start": {
"line": 34,
"character": 4
},
"end": {
"line": 34,
"character": 35
}
}
},
{
"name": "ab_deploy_env",
"kind": 15,
"range": {
"start": {
"line": 35,
"character": 4
},
"end": {
"line": 35,
"character": 28
}
},
"selectionRange": {
"start": {
"line": 35,
"character": 4
},
"end": {
"line": 35,
"character": 28
}
}
}
]
}
]
},
{
"name": "output \"instance_id\"",
"kind": 5,
"range": {
"start": {
"line": 39,
"character": 0
},
"end": {
"line": 41,
"character": 1
}
},
"selectionRange": {
"start": {
"line": 39,
"character": 0
},
"end": {
"line": 41,
"character": 1
}
},
"children": [
{
"name": "value",
"kind": 14,
"range": {
"start": {
"line": 40,
"character": 2
},
"end": {
"line": 40,
"character": 33
}
},
"selectionRange": {
"start": {
"line": 40,
"character": 2
},
"end": {
"line": 40,
"character": 33
}
}
}
]
}
]
[Trace - 12:14:03 PM] Received response 'nil - (2)' in 0ms.
Result: {
"code": -32800,
"message": "error code -32800: %!s(<nil>)"
}
[Trace - 12:14:03 PM] Received response 'textDocument/documentLink - (6)' in 229ms.
Result: [
{
"range": {
"start": {
"line": 0,
"character": 9
},
"end": {
"line": 0,
"character": 14
}
},
"target": "https://registry.terraform.io/providers/hashicorp/aws/3.63.0/docs?utm_content=documentLink&utm_medium=emacs&utm_source=terraform-ls",
"tooltip": "hashicorp/aws Documentation"
}
]
[Trace - 12:14:03 PM] Received response 'nil - (7)' in 0ms.
Result: {
"code": -32800,
"message": "error code -32800: %!s(<nil>)"
}
[Trace - 12:14:03 PM] Received response 'nil - (8)' in 0ms.
Result: {
"code": -32800,
"message": "error code -32800: %!s(<nil>)"
}
[Trace - 12:14:03 PM] Received response 'textDocument/codeAction - (11)' in 791ms.
Result: null
[Trace - 12:14:03 PM] Received response 'textDocument/codeLens - (9)' in 205ms.
Result: []
[Trace - 12:14:03 PM] Received response 'textDocument/documentSymbol - (10)' in 791ms.
Result: [
{
"name": "provider \"aws\"",
"kind": 5,
"range": {
"start": {
"line": 0,
"character": 0
},
"end": {
"line": 2,
"character": 1
}
},
"selectionRange": {
"start": {
"line": 0,
"character": 0
},
"end": {
"line": 2,
"character": 1
}
},
"children": [
{
"name": "region",
"kind": 15,
"range": {
"start": {
"line": 1,
"character": 2
},
"end": {
"line": 1,
"character": 22
}
},
"selectionRange": {
"start": {
"line": 1,
"character": 2
},
"end": {
"line": 1,
"character": 22
}
}
}
]
},
{
"name": "data \"aws_subnet\" \"galcapp_mgmt\"",
"kind": 5,
"range": {
"start": {
"line": 4,
"character": 0
},
"end": {
"line": 6,
"character": 1
}
},
"selectionRange": {
"start": {
"line": 4,
"character": 0
},
"end": {
"line": 6,
"character": 1
}
},
"children": [
{
"name": "id",
"kind": 15,
"range": {
"start": {
"line": 5,
"character": 2
},
"end": {
"line": 5,
"character": 33
}
},
"selectionRange": {
"start": {
"line": 5,
"character": 2
},
"end": {
"line": 5,
"character": 33
}
}
}
]
},
{
"name": "data \"aws_security_group\" \"mgmt_sg\"",
"kind": 5,
"range": {
"start": {
"line": 8,
"character": 0
},
"end": {
"line": 10,
"character": 1
}
},
"selectionRange": {
"start": {
"line": 8,
"character": 0
},
"end": {
"line": 10,
"character": 1
}
},
"children": [
{
"name": "id",
"kind": 15,
"range": {
"start": {
"line": 9,
"character": 2
},
"end": {
"line": 9,
"character": 29
}
},
"selectionRange": {
"start": {
"line": 9,
"character": 2
},
"end": {
"line": 9,
"character": 29
}
}
}
]
},
{
"name": "resource \"aws_instance\" \"scratch\"",
"kind": 5,
"range": {
"start": {
"line": 24,
"character": 0
},
"end": {
"line": 37,
"character": 1
}
},
"selectionRange": {
"start": {
"line": 24,
"character": 0
},
"end": {
"line": 37,
"character": 1
}
},
"children": [
{
"name": "ami",
"kind": 15,
"range": {
"start": {
"line": 25,
"character": 2
},
"end": {
"line": 25,
"character": 48
}
},
"selectionRange": {
"start": {
"line": 25,
"character": 2
},
"end": {
"line": 25,
"character": 48
}
}
},
{
"name": "subnet_id",
"kind": 14,
"range": {
"start": {
"line": 26,
"character": 2
},
"end": {
"line": 26,
"character": 56
}
},
"selectionRange": {
"start": {
"line": 26,
"character": 2
},
"end": {
"line": 26,
"character": 56
}
}
},
{
"name": "iam_instance_profile",
"kind": 15,
"range": {
"start": {
"line": 27,
"character": 2
},
"end": {
"line": 27,
"character": 62
}
},
"selectionRange": {
"start": {
"line": 27,
"character": 2
},
"end": {
"line": 27,
"character": 62
}
}
},
{
"name": "instance_type",
"kind": 15,
"range": {
"start": {
"line": 28,
"character": 2
},
"end": {
"line": 28,
"character": 35
}
},
"selectionRange": {
"start": {
"line": 28,
"character": 2
},
"end": {
"line": 28,
"character": 35
}
}
},
{
"name": "key_name",
"kind": 15,
"range": {
"start": {
"line": 29,
"character": 2
},
"end": {
"line": 29,
"character": 42
}
},
"selectionRange": {
"start": {
"line": 29,
"character": 2
},
"end": {
"line": 29,
"character": 42
}
}
},
{
"name": "security_groups",
"kind": 18,
"range": {
"start": {
"line": 30,
"character": 2
},
"end": {
"line": 30,
"character": 61
}
},
"selectionRange": {
"start": {
"line": 30,
"character": 2
},
"end": {
"line": 30,
"character": 61
}
},
"children": [
{
"name": "0",
"kind": 14,
"range": {
"start": {
"line": 30,
"character": 26
},
"end": {
"line": 30,
"character": 60
}
},
"selectionRange": {
"start": {
"line": 30,
"character": 26
},
"end": {
"line": 30,
"character": 60
}
}
}
]
},
{
"name": "tags",
"kind": 23,
"range": {
"start": {
"line": 31,
"character": 2
},
"end": {
"line": 36,
"character": 3
}
},
"selectionRange": {
"start": {
"line": 31,
"character": 2
},
"end": {
"line": 36,
"character": 3
}
},
"children": [
{
"name": "Name",
"kind": 15,
"range": {
"start": {
"line": 32,
"character": 4
},
"end": {
"line": 32,
"character": 50
}
},
"selectionRange": {
"start": {
"line": 32,
"character": 4
},
"end": {
"line": 32,
"character": 50
}
}
},
{
"name": "ab_deploy_method",
"kind": 15,
"range": {
"start": {
"line": 33,
"character": 4
},
"end": {
"line": 33,
"character": 34
}
},
"selectionRange": {
"start": {
"line": 33,
"character": 4
},
"end": {
"line": 33,
"character": 34
}
}
},
{
"name": "ab_deploy_owner",
"kind": 15,
"range": {
"start": {
"line": 34,
"character": 4
},
"end": {
"line": 34,
"character": 35
}
},
"selectionRange": {
"start": {
"line": 34,
"character": 4
},
"end": {
"line": 34,
"character": 35
}
}
},
{
"name": "ab_deploy_env",
"kind": 15,
"range": {
"start": {
"line": 35,
"character": 4
},
"end": {
"line": 35,
"character": 28
}
},
"selectionRange": {
"start": {
"line": 35,
"character": 4
},
"end": {
"line": 35,
"character": 28
}
}
}
]
}
]
},
{
"name": "output \"instance_id\"",
"kind": 5,
"range": {
"start": {
"line": 39,
"character": 0
},
"end": {
"line": 41,
"character": 1
}
},
"selectionRange": {
"start": {
"line": 39,
"character": 0
},
"end": {
"line": 41,
"character": 1
}
},
"children": [
{
"name": "value",
"kind": 14,
"range": {
"start": {
"line": 40,
"character": 2
},
"end": {
"line": 40,
"character": 33
}
},
"selectionRange": {
"start": {
"line": 40,
"character": 2
},
"end": {
"line": 40,
"character": 33
}
}
}
]
}
]
[Trace - 12:14:03 PM] Received response 'textDocument/documentLink - (12)' in 792ms.
Result: [
{
"range": {
"start": {
"line": 0,
"character": 9
},
"end": {
"line": 0,
"character": 14
}
},
"target": "https://registry.terraform.io/providers/hashicorp/aws/3.63.0/docs?utm_content=documentLink&utm_medium=emacs&utm_source=terraform-ls",
"tooltip": "hashicorp/aws Documentation"
}
]
[Trace - 12:14:08 PM] Sending notification 'textDocument/didChange'.
Params: {
"textDocument": {
"uri": "file:///Users/sopalenski/dev/terraform_scratch/main.tf",
"version": 1
},
"contentChanges": [
{
"range": {
"start": {
"line": 1,
"character": 22
},
"end": {
"line": 1,
"character": 22
}
},
"rangeLength": 0,
"text": "\n"
}
]
}
[Trace - 12:14:08 PM] Sending notification 'textDocument/didChange'.
Params: {
"textDocument": {
"uri": "file:///Users/sopalenski/dev/terraform_scratch/main.tf",
"version": 2
},
"contentChanges": [
{
"range": {
"start": {
"line": 1,
"character": 0
},
"end": {
"line": 1,
"character": 2
}
},
"rangeLength": 2,
"text": ""
}
]
}
[Trace - 12:14:08 PM] Sending notification 'textDocument/didChange'.
Params: {
"textDocument": {
"uri": "file:///Users/sopalenski/dev/terraform_scratch/main.tf",
"version": 3
},
"contentChanges": [
{
"range": {
"start": {
"line": 1,
"character": 0
},
"end": {
"line": 1,
"character": 0
}
},
"rangeLength": 0,
"text": " "
}
]
}
[Trace - 12:14:08 PM] Sending notification 'textDocument/didChange'.
Params: {
"textDocument": {
"uri": "file:///Users/sopalenski/dev/terraform_scratch/main.tf",
"version": 4
},
"contentChanges": [
{
"range": {
"start": {
"line": 2,
"character": 0
},
"end": {
"line": 2,
"character": 0
}
},
"rangeLength": 0,
"text": " "
}
]
}
[Trace - 12:14:09 PM] Sending request 'textDocument/documentSymbol - (13)'.
Params: {
"textDocument": {
"uri": "file:///Users/sopalenski/dev/terraform_scratch/main.tf"
}
}
[Trace - 12:14:09 PM] Sending request 'textDocument/codeAction - (14)'.
Params: {
"textDocument": {
"uri": "file:///Users/sopalenski/dev/terraform_scratch/main.tf"
},
"range": {
"start": {
"line": 2,
"character": 2
},
"end": {
"line": 2,
"character": 2
}
},
"context": {
"diagnostics": []
}
}
[Trace - 12:14:09 PM] Sending request 'textDocument/documentLink - (15)'.
Params: {
"textDocument": {
"uri": "file:///Users/sopalenski/dev/terraform_scratch/main.tf"
}
}
[Trace - 12:14:09 PM] Sending request 'textDocument/codeLens - (16)'.
Params: {
"textDocument": {
"uri": "file:///Users/sopalenski/dev/terraform_scratch/main.tf"
}
}
[Trace - 12:14:09 PM] Received response 'textDocument/documentSymbol - (13)' in 10ms.
Result: {
"code": -32098,
"message": "main.tf: file not found"
}
[Trace - 12:14:09 PM] Received response 'textDocument/codeAction - (14)' in 9ms.
Result: null
[Trace - 12:14:09 PM] Received response 'textDocument/documentLink - (15)' in 9ms.
Result: {
"code": -32098,
"message": "main.tf: file not found"
}
[Trace - 12:14:09 PM] Received response 'textDocument/codeLens - (16)' in 3ms.
Result: []
[Trace - 12:15:10 PM] Sending request 'textDocument/documentSymbol - (17)'.
Params: {
"textDocument": {
"uri": "file:///Users/sopalenski/dev/terraform_scratch/main.tf"
}
}
[Trace - 12:15:10 PM] Sending request 'textDocument/codeAction - (18)'.
Params: {
"textDocument": {
"uri": "file:///Users/sopalenski/dev/terraform_scratch/main.tf"
},
"range": {
"start": {
"line": 2,
"character": 2
},
"end": {
"line": 2,
"character": 2
}
},
"context": {
"diagnostics": []
}
}
[Trace - 12:15:10 PM] Sending request 'textDocument/documentLink - (19)'.
Params: {
"textDocument": {
"uri": "file:///Users/sopalenski/dev/terraform_scratch/main.tf"
}
}
[Trace - 12:15:10 PM] Received response 'textDocument/documentSymbol - (17)' in 11ms.
Result: {
"code": -32098,
"message": "main.tf: file not found"
}
[Trace - 12:15:10 PM] Received response 'textDocument/codeAction - (18)' in 11ms.
Result: null
[Trace - 12:15:10 PM] Received response 'textDocument/documentLink - (19)' in 11ms.
Result: {
"code": -32098,
"message": "main.tf: file not found"
}
Anything else?
No response
cc @psibi
Thanks for the detailed bug report @arcsteveio. Note that this is kind of a expected behavior and happens with Visual studio code too: The only difference is that visual studio doesn't show the errors whereas lsp-mode displays them in the mini buffer.
I will have to create a similar workaround like this to fix it later this week: https://github.com/emacs-lsp/lsp-mode/pull/3111
Thank you @psibi. As you said I hadn't noticed this in Visual Studio Code. I appreciate all the work you've done so far!
I don't think this is actually an expected behaviour. I've been getting the same error this morning on my Linux machine but not in VSCode (telling both to use the same binary).
Tested it with Eglot as well (since I don't have it configured I had to provide the terraform-ls binary explicitly) (lsp-bridge did the same as well):
- 0.29.2 -> Cannot find main.tf
- 0.29.1 -> Cannot find main.tf
- 0.29.0 -> Cannot find main.tf
- 0.28.1 -> Works as expected
I can sometimes get it to connect successfully after multiple disconnects/reconnects but I haven't figured out any way to get it to do so reliably enough to be usable.
@jleechpe How are you testing it in VSCode ? I can confirm that I can reproduce in both lsp-mode as well as VS Code.
Freshly installed visual-studio-code-bin on arch, added the terraform extension and tested... although now that I'm retesting it is refusing to work, which means I likely got one of those lucky circumstances (that I found once or twice in emacs as well)
I don't get any completion (other than generic text completions) in VSCode (re -> Requester, which isn't even a word in the file in question) so I don't think it's safe to ignore it
Updated the upstream bug report to say so.
@jleechpe Thanks for the upstream bug report.
I'm also seeing this issue. When editing any Terraform file I'll get
LSP :: Error from the Language Server: eks.tf: file not found (Unknown error)
errors constantly and it seems to be causing completion to break as well.
@ashlineldridge If you check https://github.com/hashicorp/terraform-ls/issues/1067 it looks like it's a problem with terraform-ls and symbolic links. As a workaround you can disable lock files in Emacs. Otherwise we'll need to wait for them to address the problem. It doesn't look like it's a problem with lsp-mode.
Thank you, @arcsteveio 🙇🏼
@arcsteveio Can you confirm if this issue is still reproducible with terraform-ls 0.30.2 ? I have been using it for a couple of days and I haven't faced it yet.
@psibi I tried out terraform-ls 0.30.2 and I can't reproduce the issue. I edit the terraform file and things still work. I think this is fixed.
@arcsteveio Thanks for the confirmation. @jleechpe I will close this issue if you can confirm it too ?