Skip to content

Commit f3e53b7

Browse files
sungchun12treyspbenfdking
authored
vscode-env-var-docs (#4803)
Co-authored-by: Trey Spiller <[email protected]> Co-authored-by: Ben <[email protected]>
1 parent af2fb95 commit f3e53b7

File tree

5 files changed

+25
-5
lines changed

5 files changed

+25
-5
lines changed

docs/guides/vscode.md

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ If you are using Tobiko Cloud, the `tcloud` library will install SQLMesh for you
5555
First, follow the [Python setup](#python-setup) steps above to create and activate a Python environment. Next, install `tcloud`:
5656

5757
```bash
58-
pip install tcloud
58+
pip install tcloud # always make sure to install the latest version of tcloud
5959
```
6060

6161
Finally, add the `lsp` extra to your `tcloud.yml` configuration file, as described [here](../cloud/tcloud_getting_started.md#connect-tobiko-cloud-to-data-warehouse).
@@ -155,11 +155,31 @@ The VSCode extension is based on a [language server](https://en.wikipedia.org/wi
155155

156156
If you have environment variables that are needed by the context and the language server, you can use one of these approaches to pass variables to the language server:
157157

158-
- Open VSCode from a terminal that has the variables set
159-
- Use environment variables pulled from somewhere else dynamically (e.g. a `.env` file) in your config
160-
- Set the environment variables in the python environment that the extension uses. You can find detailed instructions [here](https://code.visualstudio.com/docs/python/environments#_environment-variables)
158+
- Open VSCode from a terminal that has the variables set already.
159+
- If you have `export ENV_VAR=value` in your shell configuration file (e.g. `.zshrc` or `.bashrc`) when initializing the terminal by default, the variables will be picked up by the language server if opened from that terminal.
160+
- Use environment variables pulled from somewhere else dynamically in your `config.py` for example by connecting to a secret store
161+
- By default, a `.env` file in your root project directory will automatically be picked up by the language server through the python environment that the extension uses. For exact details on how to set the environment variables in the Python environment that the extension uses, see [here](https://code.visualstudio.com/docs/python/environments#_environment-variables)
161162

162-
### Python environment woes
163+
You can verify that the environment variables are being passed to the language server by printing them in your terminal.
164+
165+
1. `Cmd +Shift + P` (`Ctrl + Shift + P` in case of Windows) to start the VSCode command bar
166+
![print_env_vars](./vscode/print_env_vars.png)
167+
2. Select the option: `SQLMesh: Print Environment Variables`
168+
3. You should see the environment variables printed in the terminal
169+
![terminal_env_vars](./vscode/terminal_env_vars.png)
170+
171+
If you change your setup during development (e.g., add variables to your shell config), you must restart the language server for the changes to take effect. You can do this by running the following command in the terminal:
172+
173+
1. `Cmd +Shift + P` (`Ctrl + Shift + P` in case of Windows) to start the VSCode command bar
174+
2. Select the option: `SQLMesh: Restart Servers`
175+
![restart_servers](./vscode/restart_servers.png)
176+
![loaded](./vscode/loaded.png)
177+
178+
> This loaded message will appear in the lower left corner of the VSCode window.
179+
180+
3. Print the environment variables based on the instructions above to verify the changes have taken effect.
181+
182+
### Python environment issues
163183

164184
The most common problem is the extension not using the correct Python interpreter.
165185

docs/guides/vscode/loaded.png

21.1 KB
Loading
16 KB
Loading
11.8 KB
Loading
47.8 KB
Loading

0 commit comments

Comments
 (0)