Skip to content

Fix #19423: Add VSCMD_VER guard to conanvcvars.bat - #20223

Open
anushkagupta200615-jpg wants to merge 2 commits into
conan-io:develop2from
anushkagupta200615-jpg:fix-vcvars-issue-19423
Open

Fix #19423: Add VSCMD_VER guard to conanvcvars.bat#20223
anushkagupta200615-jpg wants to merge 2 commits into
conan-io:develop2from
anushkagupta200615-jpg:fix-vcvars-issue-19423

Conversation

@anushkagupta200615-jpg

Copy link
Copy Markdown

Changelog: Fix: VCVars generator now skips calling vcvarsall.bat if it is already active to prevent %PATH% length crashes on repeated activations.
Docs: N/A

  • Refer to the issue that supports this Pull Request.
    Fixes [bug] conanvcvars.bat should activate only once, since it can't be deactivated. #19423
  • If the issue has missing info, explain the purpose/use case/pain/need that covers this Pull Request.
    The generated conanvcvars.bat blindly called Microsoft's vcvarsall.bat every time conanbuild.bat was executed. Because Microsoft's scripts are not idempotent and have no real deactivation mechanism, repeated activations appended duplicate entries to %PATH%. This eventually caused the environment to hit the Windows character limit and crash. The generated scripts (.bat and .ps1) now include a guard that checks VSCMD_VER to skip activation if the Visual Studio developer environment is already active.
  • I've read the Contributing guide.
  • I've followed the PEP8 style guides for Python code.
  • I've opened another PR in the Conan docs repo to the develop branch, documenting this one.

@memsharded memsharded left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @anushkagupta200615-jpg

Thanks for your contribution.
This would be a duplicate of #19424

I did a review there and shared some concerns in #19424 (review). I think this change can be risky and break some users.

I think the conversation should be followed up in that PR, not open a new one, I suggest closing this one and commenting in that other PR.

@memsharded memsharded self-assigned this Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] conanvcvars.bat should activate only once, since it can't be deactivated.

2 participants