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

Activating MSVC correctly #138

Open
certik opened this issue Sep 17, 2024 · 2 comments
Open

Activating MSVC correctly #138

certik opened this issue Sep 17, 2024 · 2 comments

Comments

@certik
Copy link
Contributor

certik commented Sep 17, 2024

Right now I do:

$ cmd
> call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
> /path/to/shell.exe
$ # Now we can use MSVC, all environment variables are set correctly

This sets $PATH, so I save it using echo $PATH > msvc.sh, then go into msvc.sh and change it to export PATH='...', where ... is the original content. Then I load it using source msvc.sh. If I do this in the above inner most shell, then things keep working.

If I source msvc.sh in a new shell, then I verified that echo $PATH is identical in both shells, but MSVC does not work in the new shell. This leads me to believe that there are other variables that we need to set. It's hard to figure out which ones without #137.

@certik
Copy link
Contributor Author

certik commented Sep 17, 2024

A nicer workaround:

~$ cat ~/bin/msvc.bat
call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
C:\Users\ondrejcertik\bin\shell

And I use it like this:

~$ which cl
cl not found
~$ bin/msvc.bat

C:\Users\ondrejcertik>call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.11.3
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
~$ which cl
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\bin\HostX64\x64\cl.exe

@certik
Copy link
Contributor Author

certik commented Sep 26, 2024

It's possible to make it a one-liner almost, but it hits a bug: #159.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant