Skip to content

fix nu_msvs #1116

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

Merged
merged 2 commits into from
May 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions modules/virtual_environments/nu_msvs/nu_msvs.nu
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,18 @@ def --env find_msvs [] {
$env.MSVS_BASE_PATH = $env.Path
$env.PATH_VAR = (if "Path" in $env { "Path" } else { "PATH" })

# This is a total hack because nushell doesn't like parentheses in an environment variable like `$env.ProgramFiles(x86)`
let programfiles = $env | transpose name value | where name starts-with Program and name ends-with '(x86)' | get value.0
# According to https://github.com/microsoft/vswhere/wiki/Installing, vswhere should always be in this location.
let vswhere_cmd = $'($programfiles)\Microsoft Visual Studio\Installer\vswhere.exe'

let vswhere_cmd = ($'($env."ProgramFiles(x86)")\Microsoft Visual Studio\Installer\vswhere.exe')
let info = (
if ($vswhere_cmd | path exists) {
(^$vswhere_cmd -format json | from json)
(^$vswhere_cmd -prerelease -products '*' -format json -nocolor -utf8 -sort | from json)
} else {
# this should really error out here
('{"installationPath": [""]}' | from json)
('[{"installationPath": ""}]' | from json)
}
)

$env.MSVS_ROOT = $info.installationPath.0
$env.MSVS_ROOT = $info.0.installationPath

$env.MSVS_MSVC_ROOT = (
if not ($'($env.MSVS_ROOT)\VC\Tools\MSVC\' | path exists) {
Expand Down