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

Extension cannot read .env file or load custom environment variables. #161

Open
venturozzaccio opened this issue Dec 2, 2024 · 1 comment

Comments

@venturozzaccio
Copy link

Description

Kedro viz extension in VScode doesn't start if environment variables are to be loaded from .env or any other file nor there is a way to specify how to load them.
Kedro and Kedro viz works normally cause they are run from a terminal that have already loaded the variables.
Maybe there is a way to specify the shell environment when launching a VScode extension.

Steps to Reproduce

  1. Create a starter project
  2. Define credentials.yml with any environment variable ${oc.env:AWS_ACCESS_KEY_ID}

Expected Result

Env variables are read correctly

Actual Result

It raises an exception

Kedro-Viz: KeyError raised while resolving interpolation: "Environment variable 'AWS_ACCESS_KEY_ID' not found"
  • Kedro version used (pip show kedro or kedro -V): 0.19.10
  • Kedro VSCode version used: 0.2.3
  • Python version used (python -V): 3.11
  • Operating system and version: MacOS
@venturozzaccio
Copy link
Author

I just found a workaround.

For anyone interested, it seems that executing vscode extensions from terminals are almost impossible but it's possible to launch vscode from a shell where env variables are already defined, then all new terminals and extensions in that instance of vscode will have them preloaded.

So basically install globally dotenv and launch vscode like this:

dotenv -f .env run code .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant