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

No schema found / No root module found / Workspace not initialized / Alternative root modules found #569

Closed
radeksimko opened this issue Feb 25, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@radeksimko
Copy link
Member

radeksimko commented Feb 25, 2021

Symptoms

This is a catch-all issue for the following warning messages issued by the language server:

No schema found for .... Functionality may be limited. You may need to run terraform init.

No root module found for ... Functionality may be limited. You may need to run terraform init and reload your editor.

Alternative root modules found for ..., picked: .... You can try setting paths to root modules explicitly in settings.

Duplicates

This is an issue we'll keep open in place of the following ones:

Which doesn't mean the linked issues are in any way invalid, just that it's beneficial to keep the conversation in one place.

All of the above points to one particular root cause, which is that the language server has no schema to use for completion, hover and other functionality.

This may be because one of the following reasons:

  • the directory was not terraform init-ed, i.e. plugins were not downloaded, e.g. because
    • a nested module is being edited, which would never be init-ed on its own, but only from a parent module
    • terragrunt is in use
  • the directory was terraform init-ed, but the LS was unable to obtain the schema, e.g. because
    • remote backend is in use, which makes it difficult to obtain the schema due to authentication workflow
    • tfenv is in use and the version specified in .terraform-version is not yet installed
    • terragrunt is in use and therefore plugins cache is decoupled from the relevant directory

The list of reasons is not definitive, but these are the most commonly reported ones.

Proposed Solution

hashicorp/terraform-ls#354 describes the solution in more detail.

All of the above errors are produced by the language server and therefore the problem can and should be solved there, not on the extension side.

TL;DR of the solution is to obtain the schema through other means (not just via CLI) and combine the different sources, so that there is a schema in most/more cases, then remove both messages from LS entirely.


Feel free to leave 👍 reaction on this issue, but please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for maintainers and other issue followers and do not help with prioritization.

@radeksimko
Copy link
Member Author

Language server 0.16.0 was released yesterday. As mentioned in the changelog, this version removes all of the above warnings and should provide schema-dependent functionality in more cases due to the fact that it can now combine different sources.

It also lays down the foundations for future work on hashicorp/terraform-ls#193 and hashicorp/terraform-ls#355 Such additional sources of schema will then improve the coverage (and chances of getting relevant schema) further.

In the meantime you may still experience some inaccurate completion/hover/highlighting data (because newer/older version of provider schema was matched) or lack of the data because it's not available in the preloaded batch of official+partner providers and it was not possible to source it locally, which may have been because

Feel free to follow the mentioned issues and comment there if you feel impacted by these and feel free to file any new bugs or feature requests you find in the new version(s).

You should receive a popup prompting you to update LS in VS Code automatically.

Happy Terraforming!

@radeksimko radeksimko unpinned this issue May 5, 2021
@ghost
Copy link

ghost commented May 30, 2021

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 May 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant