Vscode-terraform: No schema found / No root module found / Workspace not initialized / Alternative root modules found

Created on 25 Feb 2021  ·  2Comments  ·  Source: hashicorp/vscode-terraform

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

https://github.com/hashicorp/terraform-ls/issues/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.

enhancement

Most helpful comment

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 https://github.com/hashicorp/terraform-ls/issues/193 and https://github.com/hashicorp/terraform-ls/issues/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!

All 2 comments

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 https://github.com/hashicorp/terraform-ls/issues/193 and https://github.com/hashicorp/terraform-ls/issues/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!

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mdschweda picture mdschweda  ·  3Comments

jacobisaliveandwell picture jacobisaliveandwell  ·  3Comments

kagarlickij picture kagarlickij  ·  5Comments

LogicNinja picture LogicNinja  ·  3Comments

tillig picture tillig  ·  4Comments