code /Users/username/src/my-terraform-modulecode /Users/username/src/markdown-wikiterraform init in /Users/username/src/markdown-wiki"It appears the language server isn't differentiating between logical workspaces. Once it's started, it assumes every open workspace is working with Terraform.
The only way to stop this is to fully quit VS Code and then _only_ open the markdown wiki (or whatever) project that isn't using Terraform.
Note: #366 is the issue where you open VS Code in a parent folder where child folders have Terraform stuff and you see this message. This issue is because when you open one VS Code workspace that does have Terraform in it; then open a _second workspace_ (a second window) that does _not_ have Terraform anywhere near it, not subdirectories, nothing else, then you still see the "not initialized" message.
that workaround does not work for me
here's my log
Launching language server: /Users/ami/.vscode/extensions/hashicorp.terraform-2.0.1/lsp/terraform-ls serve
2020/06/11 12:52:43 service.go:63: Preparing new session ...
2020/06/11 12:52:43 langserver.go:79: Starting server (pid 42938) ...
2020/06/11 12:52:43 server.go:469: Received 1 new requests
2020/06/11 12:52:43 server.go:165: Processing 1 requests
2020/06/11 12:52:43 server.go:223: Checking request for "initialize": {"processId":42822,"rootPath":"/Users/ami/doit/terraform-gke","rootUri":"file:///Users/ami/doit/terraform-gke","capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true,"resourceOperations":["create","rename","delete"],"failureHandling":"textOnlyTransactional"},"didChangeConfiguration":{"dynamicRegistration":true},"didChangeWatchedFiles":{"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]}},"executeCommand":{"dynamicRegistration":true},"configuration":true,"workspaceFolders":true},"textDocument":{"publishDiagnostics":{"relatedInformation":true},"synchronization":{"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":true,"contextSupport":true,"completionItem":{"snippetSupport":true,"commitCharactersSupport":true,"documentationFormat":["markdown","plaintext"],"deprecatedSupport":true,"preselectSupport":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]}},"hover":{"dynamicRegistration":true,"contentFormat":["markdown","plaintext"]},"signatureHelp":{"dynamicRegistration":true,"signatureInformation":{"documentationFormat":["markdown","plaintext"],"parameterInformation":{"labelOffsetSupport":true}}},"definition":{"dynamicRegistration":true,"linkSupport":true},"references":{"dynamicRegistration":true},"documentHighlight":{"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},"codeAction":{"dynamicRegistration":true,"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"codeLens":{"dynamicRegistration":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true,"prepareSupport":true},"documentLink":{"dynamicRegistration":true},"typeDefinition":{"dynamicRegistration":true,"linkSupport":true},"implementation":{"dynamicRegistration":true,"linkSupport":true},"colorProvider":{"dynamicRegistration":true},"foldingRange":{"dynamicRegistration":true,"rangeLimit":5000,"lineFoldingOnly":true},"declaration":{"dynamicRegistration":true,"linkSupport":true}}},"trace":"off","workspaceFolders":[{"uri":"file:///Users/ami/doit/terraform-gke","name":"terraform-gke"},{"uri":"file:///Users/ami/doit/terraform-gke/test","name":"test"},{"uri":"file:///Users/ami/doit/terraform-gke/terratest/modules/gcp","name":"gcp"}]}
2020/06/11 12:52:43 rpc_logger.go:29: Incoming request for "initialize" (ID 0): {"processId":42822,"rootPath":"/Users/ami/doit/terraform-gke","rootUri":"file:///Users/ami/doit/terraform-gke","capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true,"resourceOperations":["create","rename","delete"],"failureHandling":"textOnlyTransactional"},"didChangeConfiguration":{"dynamicRegistration":true},"didChangeWatchedFiles":{"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]}},"executeCommand":{"dynamicRegistration":true},"configuration":true,"workspaceFolders":true},"textDocument":{"publishDiagnostics":{"relatedInformation":true},"synchronization":{"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":true,"contextSupport":true,"completionItem":{"snippetSupport":true,"commitCharactersSupport":true,"documentationFormat":["markdown","plaintext"],"deprecatedSupport":true,"preselectSupport":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]}},"hover":{"dynamicRegistration":true,"contentFormat":["markdown","plaintext"]},"signatureHelp":{"dynamicRegistration":true,"signatureInformation":{"documentationFormat":["markdown","plaintext"],"parameterInformation":{"labelOffsetSupport":true}}},"definition":{"dynamicRegistration":true,"linkSupport":true},"references":{"dynamicRegistration":true},"documentHighlight":{"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},"codeAction":{"dynamicRegistration":true,"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"codeLens":{"dynamicRegistration":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true,"prepareSupport":true},"documentLink":{"dynamicRegistration":true},"typeDefinition":{"dynamicRegistration":true,"linkSupport":true},"implementation":{"dynamicRegistration":true,"linkSupport":true},"colorProvider":{"dynamicRegistration":true},"foldingRange":{"dynamicRegistration":true,"rangeLimit":5000,"lineFoldingOnly":true},"declaration":{"dynamicRegistration":true,"linkSupport":true}}},"trace":"off","workspaceFolders":[{"uri":"file:///Users/ami/doit/terraform-gke","name":"terraform-gke"},{"uri":"file:///Users/ami/doit/terraform-gke/test","name":"test"},{"uri":"file:///Users/ami/doit/terraform-gke/terratest/modules/gcp","name":"gcp"}]}
2020/06/11 12:52:43 exec.go:176: Starting /usr/local/bin/terraform ["terraform" "version"] in "/var/folders/q0/r6_khhqj7152fsf6mqgt2wyh0000gn/T/"...
2020/06/11 12:52:43 exec.go:142: Waiting for command to finish ...
2020/06/11 12:52:43 exec.go:168: terraform run (/usr/local/bin/terraform ["terraform" "version"], in "/var/folders/q0/r6_khhqj7152fsf6mqgt2wyh0000gn/T/", pid 42940) finished with exit code 0
2020/06/11 12:52:43 initialize.go:90: Found compatible Terraform version (0.12.26) at /usr/local/bin/terraform
2020/06/11 12:52:43 schema_storage.go:334: Adding workspace for watching: "/Users/ami/doit/terraform-gke"
2020/06/11 12:52:43 watcher.go:88: Adding "/Users/ami/doit/terraform-gke/.terraform/plugins/darwin_amd64/lock.json" for watching...
2020/06/11 12:52:43 schema_storage.go:124: Acquiring semaphore before retrieving schema for "/Users/ami/doit/terraform-gke" ...
2020/06/11 12:52:43 schema_storage.go:133: Retrieving schemas for "/Users/ami/doit/terraform-gke" ...
2020/06/11 12:52:43 exec.go:176: Starting /usr/local/bin/terraform ["terraform" "providers" "schema" "-json"] in "/Users/ami/doit/terraform-gke"...
2020/06/11 12:52:43 rpc_logger.go:45: Error for "initialize" (ID 0): [-32098] Workspace not initialized. Please run `terraform init` in /Users/ami/doit/terraform-gke
2020/06/11 12:52:43 server.go:204: Completed 1 requests [132.219677ms elapsed]
[Error - 12:52:43 PM] Server initialization failed.
Message: Workspace not initialized. Please run `terraform init` in /Users/ami/doit/terraform-gke
Code: -32098
2020/06/11 12:52:43 server.go:469: Received 1 new requests
2020/06/11 12:52:43 server.go:165: Processing 1 requests
2020/06/11 12:52:43 server.go:223: Checking request for "shutdown":
2020/06/11 12:52:43 rpc_logger.go:29: Incoming request for "shutdown" (ID 1):
2020/06/11 12:52:43 rpc_logger.go:50: Response to "shutdown" (ID 1): null
2020/06/11 12:52:43 server.go:204: Completed 1 requests [614.046ยตs elapsed]
2020/06/11 12:52:43 server.go:469: Received 1 new requests
2020/06/11 12:52:43 server.go:165: Processing 1 requests
2020/06/11 12:52:43 server.go:223: Checking request for "exit":
2020/06/11 12:52:43 rpc_logger.go:29: Incoming notification for "exit":
2020/06/11 12:52:43 exec.go:142: Waiting for command to finish ...
2020/06/11 12:52:43 schema_storage.go:116: error obtaining schemas: Unable to retrieve schemas: failed to get schemas: Execution of ["terraform" "providers" "schema" "-json"] canceled.
signal: killed
@joshpeng-quibi That might be a different issue - #366
i managed to solve it by adding this stupid file in the root directory (in my case the actual terrform files are nested in subdirectories below"
just create a file with tf extension and add
provider "null" {
version = "~> 2.0"
}
reload vscode and it should not complain
i managed to solve it by adding this stupid file in the root directory (in my case the actual terrform files are nested in subdirectories below"
just create a file with tf extension and add
provider "null" { version = "~> 2.0" }reload vscode and it should not complain
Had the same issue as using a repo with sub directories of code. This did stop the message appearing. Just confirming its working as expected though
This is a HUGE assumption for the extension to make.
I.e. that the root of the project is where you'll want to run terraform init.
This is a HUGE assumption for the extension to make.
I.e. that the root of the project is where you'll want to run terraform init.
Fully agree. Just checking if the workaround I have applied is affecting the function of the extension now. Not sure if anyone else has applied workaround and is seeing issues?
@innovia @PXPJamesCook @lqueryvg Just to be clear, #366 is the issue where you open VS Code in a parent folder where Terraform has stuff down below. Folks are already discussing workarounds there.
This issue is because once the language server starts in one VS Code window, opening a folder _anywhere else_ - not even a parent directory of Terraform stuff, just an arbitrary folder - you'll still see the "not initialized" warning because the extension assumes all open windows are handling Terraform workspaces.
It may be related, it may not, but I want folks to get the help they need _and_ I'm hoping the issue I'm seeing - which doesn't sound like the same thing you're seeing - won't get lost in this discussion.
To that end... it might help to continue the "workaround" discussion in #366 where a similar workaround was already proposed.
I believe this is now resolved in the latest versions of the VS Code extension and LS. We are continuing to track improvements to workspace organization and options for specifying root modules in #396 and https://github.com/hashicorp/terraform-ls/issues/32
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.
Most helpful comment
This is a HUGE assumption for the extension to make.
I.e. that the root of the project is where you'll want to run terraform init.