Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terraform-ls crashing while trying to retrieve schema #156

Closed
oba11 opened this issue Jun 12, 2020 · 4 comments
Closed

Terraform-ls crashing while trying to retrieve schema #156

oba11 opened this issue Jun 12, 2020 · 4 comments

Comments

@oba11
Copy link

oba11 commented Jun 12, 2020

Server Version

$ terraform-ls --version
0.3.2

Terraform Version

$ terraform --version
Terraform v0.12.26

Client Version

Sublime Text (LSP plugin) v0.11.0

Terraform Configuration Files

project/example/main.tf

resource "null_resource" "test" {
  provisioner "local-exec" {
    command = "echo hello"
  }
}

Log Output

/tmp/terraform-ls-24366.log
2020/06/12 11:56:04 serve_command.go:81: Terraform executions will be logged to /tmp/tf-exec-{{lsPid}}-{{args}}.log (interpolated at the time of execution)
2020/06/12 11:56:04 service.go:63: Preparing new session ...
2020/06/12 11:56:04 langserver.go:79: Starting server (pid 24366) ...
2020/06/12 11:56:04 server.go:469: Received 1 new requests
2020/06/12 11:56:04 server.go:165: Processing 1 requests
2020/06/12 11:56:04 server.go:223: Checking request for "initialize": {"initializationOptions":{},"processId":23355,"clientInfo":{"version":"0.10.1","name":"Sublime Text LSP"},"capabilities":{"textDocument":{"codeAction":{"dynamicRegistration":true,"codeActionLiteralSupport":{"codeActionKind":{"valueSet":[]}}},"declaration":{"dynamicRegistration":true,"linkSupport":true},"typeDefinition":{"dynamicRegistration":true,"linkSupport":true},"documentHighlight":{"dynamicRegistration":true},"hover":{"dynamicRegistration":true,"contentFormat":["markdown","plaintext"]},"publishDiagnostics":{"relatedInformation":true},"signatureHelp":{"dynamicRegistration":true,"signatureInformation":{"documentationFormat":["markdown","plaintext"],"parameterInformation":{"labelOffsetSupport":true}}},"implementation":{"dynamicRegistration":true,"linkSupport":true},"rangeFormatting":{"dynamicRegistration":true},"synchronization":{"dynamicRegistration":true,"willSave":true,"didSave":true,"willSaveWaitUntil":true},"references":{"dynamicRegistration":true},"colorProvider":{"dynamicRegistration":true},"definition":{"dynamicRegistration":true,"linkSupport":true},"formatting":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true},"documentSymbol":{"dynamicRegistration":true,"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},"completion":{"dynamicRegistration":true,"completionItemKind":{"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]},"completionItem":{"snippetSupport":true}}},"experimental":{},"workspace":{"configuration":true,"workspaceEdit":{"failureHandling":"abort","documentChanges":true},"applyEdit":true,"workspaceFolders":true,"executeCommand":{},"didChangeConfiguration":{"dynamicRegistration":true},"symbol":{"dynamicRegistration":true,"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]}}},"window":{"workDoneProgress":true}},"workspaceFolders":[{"name":"project","uri":"file:///Users/user/project"}],"rootPath":"/Users/user/project","rootUri":"file:///Users/user/project"}
2020/06/12 11:56:04 rpc_logger.go:29: Incoming request for "initialize" (ID 1): {"initializationOptions":{},"processId":23355,"clientInfo":{"version":"0.10.1","name":"Sublime Text LSP"},"capabilities":{"textDocument":{"codeAction":{"dynamicRegistration":true,"codeActionLiteralSupport":{"codeActionKind":{"valueSet":[]}}},"declaration":{"dynamicRegistration":true,"linkSupport":true},"typeDefinition":{"dynamicRegistration":true,"linkSupport":true},"documentHighlight":{"dynamicRegistration":true},"hover":{"dynamicRegistration":true,"contentFormat":["markdown","plaintext"]},"publishDiagnostics":{"relatedInformation":true},"signatureHelp":{"dynamicRegistration":true,"signatureInformation":{"documentationFormat":["markdown","plaintext"],"parameterInformation":{"labelOffsetSupport":true}}},"implementation":{"dynamicRegistration":true,"linkSupport":true},"rangeFormatting":{"dynamicRegistration":true},"synchronization":{"dynamicRegistration":true,"willSave":true,"didSave":true,"willSaveWaitUntil":true},"references":{"dynamicRegistration":true},"colorProvider":{"dynamicRegistration":true},"definition":{"dynamicRegistration":true,"linkSupport":true},"formatting":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true},"documentSymbol":{"dynamicRegistration":true,"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},"completion":{"dynamicRegistration":true,"completionItemKind":{"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]},"completionItem":{"snippetSupport":true}}},"experimental":{},"workspace":{"configuration":true,"workspaceEdit":{"failureHandling":"abort","documentChanges":true},"applyEdit":true,"workspaceFolders":true,"executeCommand":{},"didChangeConfiguration":{"dynamicRegistration":true},"symbol":{"dynamicRegistration":true,"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]}}},"window":{"workDoneProgress":true}},"workspaceFolders":[{"name":"project","uri":"file:///Users/user/project"}],"rootPath":"/Users/user/project","rootUri":"file:///Users/user/project"}
2020/06/12 11:56:04 exec.go:129: Execution will be logged to /tmp/tf-exec-24366-terraform-version.log
2020/06/12 11:56:04 exec.go:176: Starting /Users/user/.local/bin/terraform ["terraform" "version"] in "/var/folders/mr/6gwkzzjs4nldgm7gf2dbj6yw0000gn/T/"...
2020/06/12 11:56:04 exec.go:142: Waiting for command to finish ...
2020/06/12 11:56:04 exec.go:168: terraform run (/Users/user/.local/bin/terraform ["terraform" "version"], in "/var/folders/mr/6gwkzzjs4nldgm7gf2dbj6yw0000gn/T/", pid 24367) finished with exit code 0
2020/06/12 11:56:04 initialize.go:90: Found compatible Terraform version (0.12.26) at /Users/user/.local/bin/terraform
2020/06/12 11:56:04 schema_storage.go:334: Adding workspace for watching: "/Users/user/project"
2020/06/12 11:56:04 watcher.go:88: Adding "/Users/user/project/.terraform/plugins/darwin_amd64/lock.json" for watching...
2020/06/12 11:56:04 schema_storage.go:124: Acquiring semaphore before retrieving schema for "/Users/user/project" ...
2020/06/12 11:56:04 schema_storage.go:133: Retrieving schemas for "/Users/user/project" ...
2020/06/12 11:56:04 rpc_logger.go:45: Error for "initialize" (ID 1): [-32098] Workspace not initialized. Please run `terraform init` in /Users/user/project
2020/06/12 11:56:04 server.go:204: Completed 1 requests [347.208312ms elapsed]
2020/06/12 11:56:04 exec.go:129: Execution will be logged to /tmp/tf-exec-24366-terraform-providers-schema-json.log
2020/06/12 11:56:04 exec.go:176: Starting /Users/user/.local/bin/terraform ["terraform" "providers" "schema" "-json"] in "/Users/user/project"...
2020/06/12 11:56:04 server.go:469: Received 1 new requests
2020/06/12 11:56:04 server.go:165: Processing 1 requests
2020/06/12 11:56:04 server.go:223: Checking request for "shutdown":
2020/06/12 11:56:04 rpc_logger.go:29: Incoming request for "shutdown" (ID 2):
2020/06/12 11:56:04 rpc_logger.go:50: Response to "shutdown" (ID 2): null
2020/06/12 11:56:04 server.go:204: Completed 1 requests [454.168µs elapsed]
2020/06/12 11:56:04 server.go:469: Received 1 new requests
2020/06/12 11:56:04 server.go:165: Processing 1 requests
2020/06/12 11:56:04 server.go:223: Checking request for "exit":
2020/06/12 11:56:04 rpc_logger.go:29: Incoming notification for "exit":
2020/06/12 11:56:04 exec.go:142: Waiting for command to finish ...
2020/06/12 11:56:04 schema_storage.go:116: error obtaining schemas: Unable to retrieve schemas: failed to get schemas: Execution of ["terraform" "providers" "schema" "-json"] canceled.
signal: killed

/tmp/tf-exec-24366-terraform-version.log
2020/06/12 11:56:04 [INFO] Terraform version: 0.12.26
2020/06/12 11:56:04 [INFO] Go runtime version: go1.12.13
2020/06/12 11:56:04 [INFO] CLI args: []string{"/Users/user/.local/bin/terraform", "version"}
2020/06/12 11:56:04 [DEBUG] Attempting to open CLI config file: /Users/user/.terraformrc
2020/06/12 11:56:04 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2020/06/12 11:56:04 [DEBUG] checking for credentials in "/Users/user/.terraform.d/plugins"
2020/06/12 11:56:04 [DEBUG] checking for credentials in "/Users/user/.terraform.d/plugins/darwin_amd64"
2020/06/12 11:56:04 [INFO] CLI command args: []string{"version"}
2020/06/12 11:56:04 [DEBUG] checking for provider in "."
2020/06/12 11:56:04 [DEBUG] checking for provider in "/Users/user/.local/bin"
2020/06/12 11:56:04 [DEBUG] checking for provider in "/Users/user/.terraform.d/plugins"
2020/06/12 11:56:04 [DEBUG] checking for provider in "/Users/user/.terraform.d/plugins/darwin_amd64"
2020/06/12 11:56:04 [DEBUG] found provider "terraform-provider-archive_v1.3.0_x4"
2020/06/12 11:56:04 [DEBUG] found provider "terraform-provider-aws_v2.65.0_x4"
2020/06/12 11:56:04 [DEBUG] found provider "terraform-provider-datadog_v2.7.0_x4"
2020/06/12 11:56:04 [DEBUG] found provider "terraform-provider-github_v2.8.1_x4"
2020/06/12 11:56:04 [DEBUG] found provider "terraform-provider-helm_v1.0.0_x4"
2020/06/12 11:56:04 [DEBUG] found provider "terraform-provider-kubernetes_v1.11.3_x4"
2020/06/12 11:56:04 [DEBUG] found provider "terraform-provider-local_v1.4.0_x4"
2020/06/12 11:56:04 [DEBUG] found provider "terraform-provider-null_v2.1.2_x4"
2020/06/12 11:56:04 [DEBUG] found provider "terraform-provider-random_v2.2.1_x4"
2020/06/12 11:56:04 [DEBUG] found provider "terraform-provider-template_v2.1.2_x4"
2020/06/12 11:56:04 [DEBUG] found valid plugin: "template", "2.1.2", "/Users/user/.terraform.d/plugins/darwin_amd64/terraform-provider-template_v2.1.2_x4"
2020/06/12 11:56:04 [DEBUG] found valid plugin: "kubernetes", "1.11.3", "/Users/user/.terraform.d/plugins/darwin_amd64/terraform-provider-kubernetes_v1.11.3_x4"
2020/06/12 11:56:04 [DEBUG] found valid plugin: "github", "2.8.1", "/Users/user/.terraform.d/plugins/darwin_amd64/terraform-provider-github_v2.8.1_x4"
2020/06/12 11:56:04 [DEBUG] found valid plugin: "random", "2.2.1", "/Users/user/.terraform.d/plugins/darwin_amd64/terraform-provider-random_v2.2.1_x4"
2020/06/12 11:56:04 [DEBUG] found valid plugin: "null", "2.1.2", "/Users/user/.terraform.d/plugins/darwin_amd64/terraform-provider-null_v2.1.2_x4"
2020/06/12 11:56:04 [DEBUG] found valid plugin: "archive", "1.3.0", "/Users/user/.terraform.d/plugins/darwin_amd64/terraform-provider-archive_v1.3.0_x4"
2020/06/12 11:56:04 [DEBUG] found valid plugin: "aws", "2.65.0", "/Users/user/.terraform.d/plugins/darwin_amd64/terraform-provider-aws_v2.65.0_x4"
2020/06/12 11:56:04 [DEBUG] found valid plugin: "datadog", "2.7.0", "/Users/user/.terraform.d/plugins/darwin_amd64/terraform-provider-datadog_v2.7.0_x4"
2020/06/12 11:56:04 [DEBUG] found valid plugin: "helm", "1.0.0", "/Users/user/.terraform.d/plugins/darwin_amd64/terraform-provider-helm_v1.0.0_x4"
2020/06/12 11:56:04 [DEBUG] found valid plugin: "local", "1.4.0", "/Users/user/.terraform.d/plugins/darwin_amd64/terraform-provider-local_v1.4.0_x4"
2020/06/12 11:56:04 [INFO] Failed to read plugin lock file .terraform/plugins/darwin_amd64/lock.json: open .terraform/plugins/darwin_amd64/lock.json: no such file or directory

Expected Behavior

terraform-ls shouldn't crash when .tf files are not in sublime project root folder (i.e project/example/main.tf)

terraform-ls works if the .tf file is in the sublime project folder (i.e project/main.tf)

Actual Behavior

I believe terraform-ls should work when .tf files are not in the project root folder.

Steps to Reproduce

  1. Create a temporary 2-level directory structure
cd $HOME
mkdir -p project/example
  1. Open Sublime Text 3
  2. Select Project from the Tool Bar and Click on Add Folder to Project...
  3. Select project directory (created above) and Click on Open
  4. Expand project directory in the sidebar and create a file called main.tf in example directory.
  5. Check terraform-ls logs in /tmp/ folder
@radeksimko
Copy link
Member

Hi @oba11
As I can see from the log, there's incoming request for shutdown. Can you please share more lines of the log, so we can understand what may have caused the shutdown?

Thanks.

@oba11
Copy link
Author

oba11 commented Jun 12, 2020

Hello @radeksimko apologies for not coping the complete log, I've updated the log output in the issue description. Thank you

@radeksimko
Copy link
Member

radeksimko commented Jun 12, 2020

I believe this line is the most relevant:

2020/06/12 11:56:04 rpc_logger.go:45: Error for "initialize" (ID 1): [-32098] Workspace not initialized. Please run terraform init in /Users/user/project

Generally that error should have been surfaced to the UI somehow - not sure if it was or why it wasn't.

We'd like to avoid reporting this state in the future entirely as per #83 which might also explain why this is happening.

I believe terraform-ls should work when .tf files are not in the project root folder.

That is true - it is a use case we intend to support, but there's some work that needs to happen first.
I would suggest subscribing to #32 which describes many different scenarios which we intend to support, but don't support yet - many of them require similar solution.

With that I hope you don't mind me closing this issue as a duplicate of #32

The easiest workaround for now is to only open the actual workspaces with *.tf files as "root".

@ghost
Copy link

ghost commented Jul 12, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the context necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Jul 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants