From 18885634494f652d492defe7c5d85ca1421eb03c Mon Sep 17 00:00:00 2001 From: Ben King <9087625+benfdking@users.noreply.github.com> Date: Wed, 18 Jun 2025 20:41:07 +0200 Subject: [PATCH 1/3] docs: warning about environment variables --- docs/guides/vscode.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/guides/vscode.md b/docs/guides/vscode.md index fa6245ace1..6debb0065f 100644 --- a/docs/guides/vscode.md +++ b/docs/guides/vscode.md @@ -149,6 +149,14 @@ Because the VSCode extension establishes a long-running process connected to the Therefore, we do not recommend using DuckDB as a state store with the VSCode extension. +### Environment variables + +The extension runs the language server in a separate process. This inherits the environment variables of the parent vscode instance but it does not necessarily inherit the environment variables of the terminal instance. This means that if you have environment variables set in your VSCode terminal, they will not necessarily be available to the language server. Making sure that the language server has access to any variables you call upon can either be done by ensuring the variables are set in the environment the LSP runs: + +- by opening vscode from a terminal that has the variables set +- by not using environment variables but pulling them from somewhere else (e.g. a `.env` file) +- by setting the environment variables in the VSCode settings in the python extension settings that you can find detailed [here](https://code.visualstudio.com/docs/python/environments#_environment-variables) + ### Python environment woes The most common problem is the extension not using the correct Python interpreter. From 0802a75964b5023bfcec02f5d51f8253021e2c2b Mon Sep 17 00:00:00 2001 From: Ben King <9087625+benfdking@users.noreply.github.com> Date: Wed, 18 Jun 2025 23:26:43 +0200 Subject: [PATCH 2/3] reworked --- docs/guides/vscode.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/guides/vscode.md b/docs/guides/vscode.md index 6debb0065f..69c63f8dd1 100644 --- a/docs/guides/vscode.md +++ b/docs/guides/vscode.md @@ -151,11 +151,13 @@ Therefore, we do not recommend using DuckDB as a state store with the VSCode ext ### Environment variables -The extension runs the language server in a separate process. This inherits the environment variables of the parent vscode instance but it does not necessarily inherit the environment variables of the terminal instance. This means that if you have environment variables set in your VSCode terminal, they will not necessarily be available to the language server. Making sure that the language server has access to any variables you call upon can either be done by ensuring the variables are set in the environment the LSP runs: +The VSCode extension is based on a [language server](https://en.wikipedia.org/wiki/Language_Server_Protocol), which runs in the background as a separate process. When the VSCode extension starts the background language server, the server inherits variables from the environment you started VSCode in. Your VSCode instance may have a terminal instance open inside it - the language server does *not* inherit environment variables from the terminal instance in VSCode. It does not inherit variables you use when you call SQLMesh from the CLI. -- by opening vscode from a terminal that has the variables set -- by not using environment variables but pulling them from somewhere else (e.g. a `.env` file) -- by setting the environment variables in the VSCode settings in the python extension settings that you can find detailed [here](https://code.visualstudio.com/docs/python/environments#_environment-variables) +If you have other environment variables that are needed by the context and the language server, you can use one of these approaches to inject them into the language server: + +- Open vscode from a terminal that has the variables set +- Use environment variables pulled from somewhere else (e.g. a `.env` file) +- 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) ### Python environment woes From 25d4b08321c7d0271f3435af6b2e8fdc74f729ae Mon Sep 17 00:00:00 2001 From: Ben King <9087625+benfdking@users.noreply.github.com> Date: Thu, 19 Jun 2025 13:24:10 +0200 Subject: [PATCH 3/3] final touches --- docs/guides/vscode.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/guides/vscode.md b/docs/guides/vscode.md index 69c63f8dd1..a71599c056 100644 --- a/docs/guides/vscode.md +++ b/docs/guides/vscode.md @@ -151,12 +151,12 @@ Therefore, we do not recommend using DuckDB as a state store with the VSCode ext ### Environment variables -The VSCode extension is based on a [language server](https://en.wikipedia.org/wiki/Language_Server_Protocol), which runs in the background as a separate process. When the VSCode extension starts the background language server, the server inherits variables from the environment you started VSCode in. Your VSCode instance may have a terminal instance open inside it - the language server does *not* inherit environment variables from the terminal instance in VSCode. It does not inherit variables you use when you call SQLMesh from the CLI. +The VSCode extension is based on a [language server](https://en.wikipedia.org/wiki/Language_Server_Protocol) that runs in the background as a separate process. When the VSCode extension starts the background language server, the server inherits environment variables from the environment where you started VSCode. The server does *not* inherit environment variables from your terminal instance in VSCode, so it may not have access to variables you use when calling SQLMesh from the CLI. -If you have other environment variables that are needed by the context and the language server, you can use one of these approaches to inject them into the language server: +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: -- Open vscode from a terminal that has the variables set -- Use environment variables pulled from somewhere else (e.g. a `.env` file) +- Open VSCode from a terminal that has the variables set +- Use environment variables pulled from somewhere else dynamically (e.g. a `.env` file) in your config - 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) ### Python environment woes