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

Cannot start language server: Message: URI "" is not valid #158

Closed
oising opened this issue Jun 11, 2020 · 14 comments · Fixed by #172
Closed

Cannot start language server: Message: URI "" is not valid #158

oising opened this issue Jun 11, 2020 · 14 comments · Fixed by #172
Labels
bug Something isn't working

Comments

@oising
Copy link

oising commented Jun 11, 2020

Server Version

0.3.2

Terraform Version

Terraform v0.12.26

Client Version

VSCode 1.46.0

Terraform Configuration Files

provider "azurerm" {
  version = "~> 2.0"
  features { }
}

Log Output

Launching language server: c:\Users\OisinGrehan\.vscode\extensions\hashicorp.terraform-2.0.1/lsp/terraform-ls serve
2020/06/11 15:59:16 service.go:63: Preparing new session ...
2020/06/11 15:59:16 langserver.go:79: Starting server (pid 14976) ...
2020/06/11 15:59:16 server.go:469: Received 1 new requests
2020/06/11 15:59:16 server.go:165: Processing 1 requests
2020/06/11 15:59:16 server.go:223: Checking request for "initialize": {"processId":38236,"rootPath":null,"rootUri":null,"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":null}
2020/06/11 15:59:16 rpc_logger.go:29: Incoming request for "initialize" (ID 0): {"processId":38236,"rootPath":null,"rootUri":null,"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":null}
2020/06/11 15:59:16 rpc_logger.go:45: Error for "initialize" (ID 0): [-32098] URI "" is not valid
2020/06/11 15:59:16 server.go:204: Completed 1 requests [14.354ms elapsed]
[Error - 3:59:16 p.m.] Server initialization failed.
  Message: URI "" is not valid
  Code: -32098 

Expected Behavior

Language server should start.

Actual Behavior

Language server fails to start.

Steps to Reproduce

f1, "enable terraform language serve"

@chrisgallivan
Copy link

same problem here.

@radeksimko
Copy link
Member

Hi folks,
thank you for reporting this.

Am I right that when you triggered the command "Enable Terraform Language Server" from the command palette, that there was no .tf file open at that time?

We may need to look into the separation of enabling (in terms of toggling state in the config) and actually starting the server. I think it should only ever start when there is a relevant folder/file opened.

@murakest
Copy link

murakest commented Jun 12, 2020

Hi folks,
thank you for reporting this.

Am I right that when you triggered the command "Enable Terraform Language Server" from the command palette, that there was no .tf file open at that time?

We may need to look into the separation of enabling (in terms of toggling state in the config) and actually starting the server. I think it should only ever start when there is a relevant folder/file opened.

Hello,
I had opened tf file and path was set to a folder having tf code. Still the same issue, uninstall\install does not help. Everything was working fine until I upgrade to version 2.0.1

@murakest
Copy link

murakest commented Jun 12, 2020

Launching language server: c:\Users\kmurausk\.vscode\extensions\hashicorp.terraform-2.0.1/lsp/terraform-ls serve
2020/06/12 10:56:26 service.go:63: Preparing new session ...
2020/06/12 10:56:26 langserver.go:79: Starting server (pid 18132) ...
2020/06/12 10:56:26 server.go:469: Received 1 new requests
2020/06/12 10:56:26 server.go:165: Processing 1 requests
2020/06/12 10:56:26 server.go:223: Checking request for "initialize": {"processId":26736,"rootPath":null,"rootUri":null,"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":null}
2020/06/12 10:56:26 rpc_logger.go:29: Incoming request for "initialize" (ID 0): {"processId":26736,"rootPath":null,"rootUri":null,"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":null}
2020/06/12 10:56:26 rpc_logger.go:45: Error for "initialize" (ID 0): [-32098] URI "" is not valid
2020/06/12 10:56:26 server.go:204: Completed 1 requests [4.0226ms elapsed]
[Error - 10:56:26] Server initialization failed.
  Message: URI "" is not valid
  Code: -32098 
2020/06/12 10:56:26 server.go:469: Received 1 new requests
2020/06/12 10:56:26 server.go:165: Processing 1 requests
2020/06/12 10:56:26 server.go:223: Checking request for "shutdown": 
2020/06/12 10:56:26 rpc_logger.go:29: Incoming request for "shutdown" (ID 1): 
2020/06/12 10:56:26 rpc_logger.go:50: Response to "shutdown" (ID 1): null
2020/06/12 10:56:26 server.go:204: Completed 1 requests [0s elapsed]
2020/06/12 10:56:26 server.go:469: Received 1 new requests
2020/06/12 10:56:26 server.go:165: Processing 1 requests
2020/06/12 10:56:26 server.go:223: Checking request for "exit": 
2020/06/12 10:56:26 rpc_logger.go:29: Incoming notification for "exit": 

@radeksimko
Copy link
Member

I'm going to transfer this over to the VSCode repository, as I think the best course of action here would be preventing the VSCode extension from ever sending empty URI as part of initialization.

There isn't much the server can do without a valid URI unless it would scan the whole filesystem - but even then it's unclear why would it be initialized when there is nothing for it to do at the time.

@radeksimko radeksimko transferred this issue from hashicorp/terraform-ls Jun 12, 2020
@chrisgallivan
Copy link

I had a tf file open at the time.

The problem has since stopped for me. I now can't get the code complete to work for tf files

@radeksimko
Copy link
Member

Actually I take what I said above back after re-reading some relevant codepaths.

The client would regularly send empty URI when a single file is opened (as opposed to a directory), which is something we don't support yet, but hopefully will.

That error message is however confusing, we should be returning entirely different one, so that may need fixing, before we implement single file support.

@radeksimko radeksimko transferred this issue from hashicorp/vscode-terraform Jun 12, 2020
@radeksimko
Copy link
Member

For context the single file support is tracked under #32 but I will keep this issue open until we fix the confusing messaging around this.

@oising
Copy link
Author

oising commented Jun 12, 2020

I opened VS, created new file, saved it as .tf then tried to start the LS. @radeksimko - you're saying it will work if I open a folder instead of a single file?

EDIT: yes, using VS code's "open folder..." instead of "open file..." works. Also fails if you open with no workspace and use "new file..."

@radeksimko
Copy link
Member

radeksimko commented Jun 12, 2020

@oising Generally only the simplest scenario currently works, which can be described as

  • having a folder, which was terraform initd prior to opening it in VSCode (or any other IDE)
  • the same folder is opened as "root" in VSCode (or any other IDE)
  • the folder does not contain any subfolder, or you don't open files in these subfolders

#32 lists a number of scenarios which don't work yet (but will eventually, when we implement it). Vast majority of the ones we don't support yet is surfaced as "Workspace not initialized". That message can be misleading in many valid scenarios, but that is the current state of things.

@techadmin1982
Copy link

why was this case closed ? has this problem resolved ?

@dguymon
Copy link

dguymon commented Jun 21, 2020

I was able to resolve the same issue on my end by ensuring that my $PATH environment variable in my ~/.bash_profile file was fully-qualified (i.e. no ~ in the URI), that I opened the top-level folder container all the Terraform code within the repository in VSCode, and ensuring I had previously run terraform init in the project before doing so to suppress the various language server errors from the VSCode Terraform plugin during VSCode launch.

@radeksimko
Copy link
Member

Editing single files will be reported correctly from the next release (probably 0.4.0; to be released in coming days) as "Editing a single file is not yet supported. Please open a directory.". That is why this was closed as part of #172 (which the closing event mentions).

Supporting single files as something yet to be solved as part of #32
Please follow that issue if you are interested in knowing when we support single files.

@ghost
Copy link

ghost commented Jul 19, 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 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants