Skip to content

Commit 6de2595

Browse files
committed
feat: add configuration option to include PATH when updating VS Code environment variables using mise env
1 parent d0185fa commit 6de2595

4 files changed

Lines changed: 29 additions & 3 deletions

File tree

docs/src/content/docs/reference/Settings.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,14 @@ Update VSCode and terminal environment variables automatically based on the mise
185185

186186
---
187187

188+
##### `mise.updateEnvAutomaticallyIncludePath`
189+
- **Type:** `boolean`
190+
- **Default:** `false`
191+
192+
Include the PATH variable when updating VSCode and terminal environment variables. Disable this if you want to keep your original PATH.
193+
194+
---
195+
188196
##### `mise.updateOpenTerminalsEnvAutomatically`
189197
- **Type:** `boolean`
190198
- **Default:** `false`

package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,13 @@
303303
"default": true,
304304
"markdownDescription": "Update VSCode and terminal environment variables automatically based on the mise configuration. Note that depending on the extensions loading order, other extensions might not see all mise environment variables."
305305
},
306+
"mise.updateEnvAutomaticallyIncludePath": {
307+
"order": 12.1,
308+
"type": "boolean",
309+
"title": "Include PATH when updating environment variables",
310+
"default": false,
311+
"markdownDescription": "Include the PATH variable when updating VSCode and terminal environment variables. Disable this if you want to keep your original PATH."
312+
},
306313
"mise.updateOpenTerminalsEnvAutomatically": {
307314
"order": 13,
308315
"type": "boolean",

src/configuration.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export const CONFIGURATION_FLAGS = {
1919
showOutdatedToolGutterDecorations: "showOutdatedToolGutterDecorations",
2020
checkForNewMiseVersion: "checkForNewMiseVersion",
2121
updateEnvAutomatically: "updateEnvAutomatically",
22+
updateEnvAutomaticallyIncludePATH: "updateEnvAutomaticallyIncludePATH",
2223
updateOpenTerminalsEnvAutomatically: "updateOpenTerminalsEnvAutomatically",
2324
teraAutoCompletion: "teraAutoCompletion",
2425
automaticallyTrustMiseConfigFiles: "automaticallyTrustMiseConfigFiles",
@@ -139,6 +140,13 @@ export const shouldUpdateEnv = () => {
139140
return getConfOrElse(CONFIGURATION_FLAGS.updateEnvAutomatically, true);
140141
};
141142

143+
export const shouldUpdateEnvAutomaticallyIncludePATH = () => {
144+
return getConfOrElse(
145+
CONFIGURATION_FLAGS.updateEnvAutomaticallyIncludePATH,
146+
true,
147+
);
148+
};
149+
142150
export const shouldAutomaticallyReloadTerminalEnv = () => {
143151
return getConfOrElse(
144152
CONFIGURATION_FLAGS.updateOpenTerminalsEnvAutomatically,

src/providers/envProvider.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
isMiseExtensionEnabled,
1616
shouldAutomaticallyReloadTerminalEnv,
1717
shouldUpdateEnv,
18+
shouldUpdateEnvAutomaticallyIncludePATH,
1819
} from "../configuration";
1920
import type { MiseService } from "../miseService";
2021
import { logger } from "../utils/logger";
@@ -381,9 +382,11 @@ export async function updateEnv(
381382
}
382383

383384
const currentEnvs = new Map(
384-
miseEnvs
385-
.filter(({ name }) => name.toUpperCase() !== "PATH")
386-
.map(({ name, value }) => [name, value]),
385+
shouldUpdateEnvAutomaticallyIncludePATH()
386+
? miseEnvs.map(({ name, value }) => [name, value])
387+
: miseEnvs
388+
.filter(({ name }) => name.toUpperCase() !== "PATH")
389+
.map(({ name, value }) => [name, value]),
387390
);
388391

389392
if (previousEnvs.size === 0) {

0 commit comments

Comments
 (0)