Skip to content
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

Getting VS Kit Environment fails silently when VS instance not found #3644

Closed
SimonBoorer opened this issue Mar 10, 2024 · 2 comments
Closed
Assignees
Labels
bug a bug in the product Feature: kits suggested Temporary label for internal tracking for suggested bugs to pick up in spare time.
Milestone

Comments

@SimonBoorer
Copy link

SimonBoorer commented Mar 10, 2024

Brief Issue Summary

I've been using the CMake Tools extension with the Visual Studio generator for some time without issue. I swapped to using Ninja and was struggling with it using the wrong compiler. After enabling debug logging I found that this was because the environment variables from vcvaralls.bat were not being applied. I had to debug the vscode-cmake-tools extension to work out that the reason why was that at some point my VS Install instance ID had changed so my cmake-tools-kits.json was outdated. Running Scan for Kit updated the instance ID which fixed the issue.

It would be good if there were some kind of warning or error message when the VS instance was not found, and perhaps a suggestion to re-scan for kits:

export async function getVSKitEnvironment(kit: Kit): Promise<Environment | null> {
    const requested = await getVSInstallForKit(kit);
    if (!requested) {
        return null;
    }

    return varsForVSInstallation(requested, kit.visualStudioArchitecture!, kit.preferredGenerator?.platform);
}

async function getVSInstallForKit(kit: Kit): Promise<VSInstallation | undefined> {
    if (process.platform !== "win32") {
        return undefined;
    }

    console.assert(kit.visualStudio);
    console.assert(kit.visualStudioArchitecture);

    const installs = await vsInstallations();
    const match = (inst: VSInstallation) =>
        // old Kit format
        (legacyKitVSName(inst) === kit.visualStudio) ||
        // new Kit format
        (kitVSName(inst) === kit.visualStudio) ||
        // Clang for VS kit format
        (!!kit.compilers && kit.name.indexOf("Clang") >= 0 && kit.name.indexOf(vsDisplayName(inst)) >= 0);

    return installs.find(match);
}

CMake Tools Diagnostics

No response

Debug Log

No response

Additional Information

No response

@gcampbell-msft
Copy link
Collaborator

@SimonBoorer This is definitely something that would be nice. I will add this to our backlog. THanks.

@gcampbell-msft gcampbell-msft added bug a bug in the product Feature: kits and removed triage labels Mar 13, 2024
@gcampbell-msft gcampbell-msft added this to the Backlog milestone Mar 13, 2024
@gcampbell-msft gcampbell-msft modified the milestones: Backlog, On Deck Apr 23, 2024
@gcampbell-msft gcampbell-msft added the suggested Temporary label for internal tracking for suggested bugs to pick up in spare time. label Apr 24, 2024
@andreeis andreeis self-assigned this May 19, 2024
@gcampbell-msft
Copy link
Collaborator

Closing, fixed in #3775

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug a bug in the product Feature: kits suggested Temporary label for internal tracking for suggested bugs to pick up in spare time.
Projects
Status: Completed
Development

No branches or pull requests

3 participants