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

Various errors with kakoune + kak-ls #129

Closed
michaelssingh opened this issue Jun 1, 2020 · 8 comments
Closed

Various errors with kakoune + kak-ls #129

michaelssingh opened this issue Jun 1, 2020 · 8 comments
Labels
bug Something isn't working editor/kakoune https://kakoune.org/ question Further information is requested waiting-response

Comments

@michaelssingh
Copy link

michaelssingh commented Jun 1, 2020

Server Version

0.2.1

Terraform Version

Terraform v0.12.26

Client Version

kakoune-2020.01.16-1.fc32.x86_64
kak-lsp 8.0.0

Terraform Configuration Files

luser@halcyon ~/d/w/c/e/terraform (master)> cat main.tf
terraform {
  required_version = ">= 0.12.0"
  backend "s3" {
    encrypt        = true
    bucket         = [redacted]
    region         = "eu-central-1"
    key            = "tf"
    dynamodb_table = "infra-lock-logs"
    role_arn       = [redacted]
  }
}

provider "aws" {
  version = "~> 2.0"
  region  = "eu-central-1"
  assume_role {
[redacted]
  }
}

provider "aws" {
  version = "~> 2.0"
  region  = "eu-central-1"
  alias   = "eu-central-1"
  assume_role {
[redacted]
  }
}

module "account-info" {
[redacted]
}

module "vpc-eu-central-1" {
[redacted]
}

module "cloudtrail" {
 [redacted]
  }
}

module "humio" {
[redacted]
}

Log Output

https://gist.github.com/michaelssingh/7c26c8f4c98680a61f1e4fbcc5e6783e

Expected Behavior

Completions should work

Actual Behavior

Errors in Kakoune such as:
terraform language server error: 'finding HCL block failed: no block found at hcl.Pos ...
terraform language server error: 'finding completion items failed: no schema available
`

Steps to Reproduce

  1. install kakoune
  2. install kak-lsp
  3. ~/.config/kak/kakrc && ~/.config/kak-lsp/kak-lsp.toml
  4. Add
luser@halcyon ~/d/w/c/e/terraform (master)> cat ~/.config/kak-lsp/kak-lsp.toml
snippet_support = true
verbosity = 2

[semantic_scopes]
# Map textmate scopes to kakoune faces for semantic highlighting
# the underscores are translated to dots, and indicate nesting.
# That is, if variable_other_field is omitted, it will try the face for
# variable_other and then variable
#
# To see a list of available scopes in the debug buffer, run lsp-semantic-available-scopes
variable = "variable"
entity_name_function = "function"
entity_name_type = "type"
variable_other_enummember = "variable"
entity_name_namespace = "module"

[server]
# exit session if no requests were received during given period in seconds
# works only in unix sockets mode (-s/--session)
# set to 0 to disable
timeout = 1800 # seconds = 30 minutes

[language.terraform]
filetypes = ["terraform"]
roots = ["*.tf"]
command = "terraform-ls"
args = ["serve"]

&&

luser@halcyon ~/d/w/c/e/terraform (master)> cat ~/.config/kak/kakrc
eval %sh{kak-lsp --kakoune -s $kak_session}
hook global WinSetOption filetype=(terraform|haskell) %{
        lsp-enable-window
}
  1. open open some terraform with kak and type around
  2. errors should be visible in the editor
@paultyng paultyng added the editor/kakoune https://kakoune.org/ label Jun 1, 2020
@michaelssingh
Copy link
Author

@paultyng this issue also exists on neovim

@paultyng paultyng added the editor/vim https://www.vim.org/ label Jun 4, 2020
@radeksimko
Copy link
Member

radeksimko commented Jun 4, 2020

👋 @michaelssingh
Unfortunately the link to the log returns 404.

Generally speaking, as I mentioned in #84 (comment) the language server currently isn't very useful without schema - the only thing it can really do without it is formatting. That is why it's currently treated as a requirement and it is communicated as such per #84

That said as we expand the functionality it will become more useful without the schema - e.g. completion of variable, output, module, terraform blocks, built-in functions or completion of meta-arguments like count, provider's version etc. and then we can treat it as not-essential - this work is tracked under #83

It's hard to tell however if this is related to your issue without seeing the server log, especially the beginning of it, where server receives initialize request and attempts to obtain schema. Do you mind providing it as per the linked troubleshooting guide?

Thanks.

@radeksimko radeksimko added bug Something isn't working question Further information is requested and removed editor/kakoune https://kakoune.org/ editor/vim https://www.vim.org/ labels Jun 4, 2020
@michaelssingh
Copy link
Author

@radeksimko 👋

I've included a link to the gist with the logs.

What exactly is the schema and how do I get it?

@radeksimko
Copy link
Member

radeksimko commented Jun 4, 2020

@michaelssingh Unfortunately this is log from the client side, can you please follow the guide I linked above and provide the server-side log?

https://github.com/hashicorp/terraform-ls/blob/master/docs/TROUBLESHOOTING.md

Thanks.

The schema will be obtained automatically by the language server, as long as you ran terraform init in the given directory (prior to opening the IDE), but again - I'm unsure if the lack of schema is really the issue here, as I haven't seen the server log, so I'm just guessing.

@michaelssingh
Copy link
Author

I thought that these were logs from the language server.

@radeksimko
Copy link
Member

Indeed - I'm sorry for missing that part of the log!

It looks like this is the main culprit:

2020/06/01 10:41:58 schema_storage.go:112: error obtaining schemas: Unable to retrieve schemas: failed to get schemas: terraform (pid 53474) exited (code 1): exit status 1
stdout: ""
stderr: "\x1b[31m\n\x1b[1m\x1b[31mError: \x1b[0m\x1b[0m\x1b[1mNo valid credential sources found for AWS Provider.\n\tPlease see https://terraform.io/docs/providers/aws/index.html for more information on\n\tproviding credentials for the AWS Provider\x1b[0m\n\n\x1b[0m\x1b[0m\x1b[0m\n"

which seems like the same problem we discussed recently in #128 (comment)

Do you mind me closing this issue and continue the conversation there? That thread also mentions a workaround.

@radeksimko radeksimko added the editor/kakoune https://kakoune.org/ label Jul 2, 2020
@radeksimko
Copy link
Member

As discussed, the main culprit here seems to have been the schema, which is something we are addressing on multiple fronts, most recently @appilon raised #302 which preloads schema at least for the official providers (latest as of build time).

Feel free to subscribe to #193 which discusses what might be a more scalable and sustainable solution for this problem, along with hashicorp/terraform#24261

Aside from that though I struggled to get Kakoune set up with the kak-lsp. I think there may be some conflicts between the language server functionality - namely completion - and the built-in one https://github.com/mawww/kakoune/blob/b765fb4971db28bac608abc5cd856a9cb94fcfe1/rc/filetype/terraform.kak

PR is welcomed https://github.com/hashicorp/terraform-ls/blob/master/docs/USAGE.md to describe a functional kakoune setup.

@ghost
Copy link

ghost commented Dec 17, 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 as resolved and limited conversation to collaborators Dec 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working editor/kakoune https://kakoune.org/ question Further information is requested waiting-response
Projects
None yet
Development

No branches or pull requests

3 participants