From 3c32fbfade8da4330561c1e05f3c89794a338450 Mon Sep 17 00:00:00 2001 From: "S. Abid Hashimi" Date: Tue, 3 Jun 2025 02:10:20 +0200 Subject: [PATCH] Prepend INCLUDE env, instead of override (#1127) This small fix prepends the `INCLUDE` environment variable instead of overriding it. This is important if one has already added paths to this environment, for example, in cases where one needs a common set of codebase that gets included in all C/C++ projects (such as utility functions and such). --- modules/virtual_environments/nu_msvs/nu_msvs.nu | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/modules/virtual_environments/nu_msvs/nu_msvs.nu b/modules/virtual_environments/nu_msvs/nu_msvs.nu index 71f1995..93fe9b2 100644 --- a/modules/virtual_environments/nu_msvs/nu_msvs.nu +++ b/modules/virtual_environments/nu_msvs/nu_msvs.nu @@ -1,6 +1,7 @@ def --env find_msvs [] { export-env { $env.MSVS_BASE_PATH = $env.Path + $env.INCLUDE_BEFORE = if "INCLUDE" in $env { ($env.INCLUDE | split row (char esep)) } else { null } $env.PATH_VAR = (if "Path" in $env { "Path" } else { "PATH" }) # According to https://github.com/microsoft/vswhere/wiki/Installing, vswhere should always be in this location. @@ -161,8 +162,8 @@ export def --env activate [ } load-env { $env.PATH_VAR: $env_path, - INCLUDE: $env.MSVS_INCLUDE_PATH, - LIB: $lib_path + INCLUDE: ($env.MSVS_INCLUDE_PATH | append $env.INCLUDE_BEFORE), + LIB: $lib_path, } # Debug Information @@ -181,7 +182,6 @@ export def --env deactivate [] { $env.PATH_VAR: $env.MSVS_BASE_PATH, } - hide-env INCLUDE hide-env LIB hide-env MSVS_BASE_PATH hide-env MSVS_ROOT @@ -189,4 +189,13 @@ export def --env deactivate [] { hide-env MSVS_MSDK_ROOT hide-env MSVS_MSDK_VER hide-env MSVS_INCLUDE_PATH -} + + if $env.INCLUDE_BEFORE == null { + hide-env INCLUDE + } else { + load-env { + INCLUDE: ($env.INCLUDE_BEFORE | path expand | str join (char esep)) + } + hide-env INCLUDE_BEFORE + } +} \ No newline at end of file