-
Notifications
You must be signed in to change notification settings - Fork 211
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
LSP complains about missing environment variables #1524
Comments
@akshaymankar: You can use the alternative import operator to provide a fallback expression if import resolution fails, like this: env:SOME_SECRET as Text ? "fallback value" |
It would work for things which can have defaults. For things which cannot, I'd really like them to fail when environment variables are not provided while resolving expressions with |
I guess we could make an option where "Skipping" |
@sjakobi: Note that that is already possible by setting the environment variable in the environment the language server runs in:
|
@Gabriel439 I imagine that this would become somewhat tedious when there are many I wanted to suggest an option where every import of the form In principle, something similar could be done for |
@sjakobi: We don't actually have to resolve the import to type-check the file in that case. We only need the type of the import (which we can infer from the |
I thought we need the/a value when the import appears in a |
@sjakobi: Conceptually we could modify the type-checker to support an expression with unresolved imports, so long as all imports were of the form |
That might actually be a nice idea – but it also sounds quite a bit more complex than the stubbing… |
@sjakobi: Stubbing in a fake value seems too unprincipled to me and could lead to unintended consequences. Faking success with an in-band value (e.g. 0, |
I don't see how it's much worse than asking the user to provide fake values – which admittedly we could also simplify by accepting env-vars from a |
Maybe I should ask: How do you work on Dhall configurations that |
@sjakobi: I provide a fallback import using |
@Gabriel439 Then you probably don't import any secrets via Maybe we should find out how other users who configure secrets via Dhall access them and how they replace them during development. |
@sjakobi: Yeah, that's correct. We currently don't use |
@akshaymankar Do you already have a workaround for this issue? I think you could otherwise easily set stub values with a script based on
@Gabriel439 Could you elaborate on what kind of bad things you believe could happen if we add an option that fakes Regarding the idea of delaying import resolution – I'm not yet convinced that it's worth giving up the current neat phase separation of |
@sjakobi: It wouldn't be violating phase separation. It can be done entirely within the type-checking phase without resolving any imports. It's actually a tiny change to the standard to implement, which is just add a type-checking judgment for an |
Ah, I see! So we'd have something like a |
@sjakobi: The main change is that the type of the type-checking function would change to accept either It also wouldn't require a flag: it could just be the default behavior for |
@sjakobi I faced this problem while writing concourse pipelines in Dhall. I was resolving my secret's after translating dhall to yaml using concourse's CLI by putting Generating stubs just before starting the lsp-server is definitely a better workaround in terms of use cases. However, it would very likely require restarting the lsp-server while writing code, which would be a little inconvenient but most LSP frontends have an easy restart shortcut. I might end up wrapping lsp-server with some bash which does this. I am sure I will need this workaround sooner or later as I write more things in dhall 😄 (Kubernetes is next, I think). |
If we really wanted to we could easily add a list of env's to be stubbed as a config option, so you wouldn't have to reload anything. With per-workspace configuration that could be quite usable. Come to think of it, being able to specify environment variables to Dhall in the LSP config would be useful in any case! Waiting on #1533. |
Most of the time when I am writing dhall, I don't have the secrets/configs that I want to source from the environment, and it would be nice if I could keep it that way, otherwise setting up Emacs/Vim would become more complex that I'd like.
So, I was wondering if it would be better if LSP just ignored env import errors and continued validating rest of the expression.
The text was updated successfully, but these errors were encountered: