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

Setting up VC environment variables failed (WINDOWSSDKDIR) - bazel 4.0.0 #13261

Open
pabloVecchio opened this issue Mar 23, 2021 · 3 comments
Open
Labels
area-Windows Windows-specific issues and feature requests help wanted Someone outside the Bazel team could own this P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Documentation Documentation improvements that cannot be directly linked to other team labels team-Rules-CPP Issues for C++ rules type: documentation (cleanup)

Comments

@pabloVecchio
Copy link

Description of the problem / feature request:

Trying to follow : https://docs.bazel.build/versions/master/tutorial/java.html
can't build 'Bazel Tutorial: Build a Java Project' -> bazel build //:ProjectRunner

What operating system are you running Bazel on?

Windows 10 Pro - Version 1909

What's the output of bazel info release?

release 4.0.0

Have you found anything relevant by searching the web?

This seems to be a similar issue but the proposed solution didn't work
#8943

Any other information, logs, or outputs that you want to share?

C:\Users\Username\Desktop\Working\j2cl\samples\bazelExample\examples\java-tutorial>bazel build //:ProjectRunner
Starting local Bazel server and connecting to it...
INFO: Repository local_config_cc instantiated at:
/DEFAULT.WORKSPACE.SUFFIX:342:13: in
C:/users/Username/_bazel_Username/smr4z376/external/bazel_tools/tools/cpp/cc_configure.bzl:184:16: in cc_configure
Repository rule cc_autoconf defined at:
C:/users/Username/_bazel_Username/smr4z376/external/bazel_tools/tools/cpp/cc_configure.bzl:145:30: in
ERROR: An error occurred during the fetch of repository 'local_config_cc':
Traceback (most recent call last):
File "C:/users/Username/_bazel_Username/smr4z376/external/bazel_tools/tools/cpp/cc_configure.bzl", line 122, column 36, in cc_autoconf_impl
configure_windows_toolchain(repository_ctx)
File "C:/users/Username/_bazel_Username/smr4z376/external/bazel_tools/tools/cpp/windows_cc_configure.bzl", line 784, column 35, in configure_windows_toolchain
msvc_vars_x64 = _get_msvc_vars(repository_ctx, paths, "x64")
File "C:/users/Username/_bazel_Username/smr4z376/external/bazel_tools/tools/cpp/windows_cc_configure.bzl", line 632, column 32, in _get_msvc_vars
env = setup_vc_env_vars(repository_ctx, vc_path)
File "C:/users/Username/_bazel_Username/smr4z376/external/bazel_tools/tools/cpp/windows_cc_configure.bzl", line 387, column 24, in setup_vc_env_vars
_check_env_vars(env_map, cmd, expected = envvars)
File "C:/users/Username/_bazel_Username/smr4z376/external/bazel_tools/tools/cpp/windows_cc_configure.bzl", line 393, column 32, in _check_env_vars
auto_configure_fail(
File "C:/users/Username/_bazel_Username/smr4z376/external/bazel_tools/tools/cpp/lib_cc_configure.bzl", line 112, column 9, in auto_configure_fail
fail("\n%sAuto-Configuration Error:%s %s\n" % (red, no_color, msg))
Error in fail:
Auto-Configuration Error: Setting up VC environment variables failed, WINDOWSSDKDIR is not set by the following command: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\VCVARSALL.BAT" amd64 -vcvars_ver=14.28.29910
ERROR: Error fetching repository: Traceback (most recent call last):
File "C:/users/Username/_bazel_Username/smr4z376/external/bazel_tools/tools/cpp/cc_configure.bzl", line 122, column 36, in cc_autoconf_impl
configure_windows_toolchain(repository_ctx)
File "C:/users/Username/_bazel_Username/smr4z376/external/bazel_tools/tools/cpp/windows_cc_configure.bzl", line 784, column 35, in configure_windows_toolchain
msvc_vars_x64 = _get_msvc_vars(repository_ctx, paths, "x64")
File "C:/users/Username/_bazel_Username/smr4z376/external/bazel_tools/tools/cpp/windows_cc_configure.bzl", line 632, column 32, in _get_msvc_vars
env = setup_vc_env_vars(repository_ctx, vc_path)
File "C:/users/Username/_bazel_Username/smr4z376/external/bazel_tools/tools/cpp/windows_cc_configure.bzl", line 387, column 24, in setup_vc_env_vars
_check_env_vars(env_map, cmd, expected = envvars)
File "C:/users/Username/_bazel_Username/smr4z376/external/bazel_tools/tools/cpp/windows_cc_configure.bzl", line 393, column 32, in _check_env_vars
auto_configure_fail(
File "C:/users/Username/_bazel_Username/smr4z376/external/bazel_tools/tools/cpp/lib_cc_configure.bzl", line 112, column 9, in auto_configure_fail
fail("\n%sAuto-Configuration Error:%s %s\n" % (red, no_color, msg))
Error in fail:
Auto-Configuration Error: Setting up VC environment variables failed, WINDOWSSDKDIR is not set by the following command: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\VCVARSALL.BAT" amd64 -vcvars_ver=14.28.29910
ERROR: C:/users/Username/desktop/working/j2cl/samples/bazelexample/examples/java-tutorial/BUILD:3:12: //:ProjectRunner depends on @local_config_cc//:cc-compiler-x64_windows in repository @local_config_cc which failed to fetch. no such package '@local_config_cc//':
Auto-Configuration Error: Setting up VC environment variables failed, WINDOWSSDKDIR is not set by the following command: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\VCVARSALL.BAT" amd64 -vcvars_ver=14.28.29910
ERROR: Analysis of target '//:ProjectRunner' failed; build aborted: Analysis failed
INFO: Elapsed time: 29.432s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (11 packages loaded, 18 targets configured)


As the error says, WINDOWSSDKDIR is not being set. However PATH, LIB and INCLUDE are.
image


Running 'vcvarsall.bat amd64' with 'set VSCMD_DEBUG=3
'vcvarsall.bat amd64' with 'set VSCMD_DEBUG=3'.txt
'


Visual Studio Build Tools installed
image
Already tried uninstalling, restarting, installing Visual Studio Build Tools and Visual Studio. The same with Windows SDK

@oquenchil oquenchil added area-Windows Windows-specific issues and feature requests team-Rules-Java Issues for Java rules type: documentation (cleanup) untriaged labels Mar 24, 2021
@comius comius added team-Rules-CPP Issues for C++ rules and removed team-Rules-Java Issues for Java rules labels May 5, 2021
@comius
Copy link
Contributor

comius commented May 5, 2021

The problem seems to be in Cc autoconfiguration, or am I missing something?

I checked if we could remove Cc toolchain from Java rules, but this doesn't seem possible, because Cc can be used to build Java launcher.

@oquenchil oquenchil added P3 We're not considering working on this, but happy to review a PR. (No assignee) and removed untriaged labels May 10, 2021
@garymm
Copy link

garymm commented Sep 13, 2022

I fixed this by installing the Windows SDK from the visual studio installer.

@ShreeM01 ShreeM01 added the team-Documentation Documentation improvements that cannot be directly linked to other team labels label Jan 10, 2023
@keertk keertk added the help wanted Someone outside the Bazel team could own this label Jan 17, 2023
@albertocavalcante
Copy link

I think it's very unlikely someone will incur into the same issue I am but it happens I have on my machine a cmdrc.cmd file to mimic a .bashrc / .zshrc.

It hooks into every cmd.exe process and for some reason vsdevcmd.bat``couldn't deal with it. Solution was to have all lines as @REM` for now.

Then I was able to sucessfully run:

"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\VCVARSALL.BAT" amd64  -vcvars_ver=14.40.33807

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Windows Windows-specific issues and feature requests help wanted Someone outside the Bazel team could own this P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Documentation Documentation improvements that cannot be directly linked to other team labels team-Rules-CPP Issues for C++ rules type: documentation (cleanup)
Projects
None yet
Development

No branches or pull requests

7 participants