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

Bazel on Windows: improve first-time experience #5254

Closed
8 of 21 tasks
laszlocsomor opened this issue May 24, 2018 · 27 comments
Closed
8 of 21 tasks

Bazel on Windows: improve first-time experience #5254

laszlocsomor opened this issue May 24, 2018 · 27 comments
Labels
area-Windows Windows-specific issues and feature requests P3 We're not considering working on this, but happy to review a PR. (No assignee) stale Issues or PRs that are stale (no activity for 30 days) team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website type: process

Comments

@laszlocsomor
Copy link
Contributor

laszlocsomor commented May 24, 2018

In the spirit of #5208, I'd like to collect ideas to improve the experience of first-time Bazel on Windows users. Some ideas may be Windows-specific, some may cover all platforms. I believe the experience is bumpier than it could be.

I'm opening this bug with the intent of collecting these ideas -- mine and everyone else's -- and use it as a burn-down list of improvements. Please feel free to add your ideas. I'll keep updating the list as tasks are completed.


  • Website, "Get Bazel" button: make it point directly to the binary.
  • Make it so that the user doesn't have to rename the Bazel binary to bazel.exe.
  • Consider turning the downloadable file into an installer: that'd remove the need to rename the binary, to set up the PATH manually, and to install the VC runtime DLLs separately.
  • Website, somewhere near download link: say it's a command line tool, there's no installer. Or: turn Bazel into an installer.
  • Website, installation:
  • Workspace path may not contain space. Should be supported.
  • Renaming the workspace fails because the Bazel server is running in it.
  • No VC installed, but Bazel gives warnings (or status messages?) about VC discovery.
  • Document {java,py}_binary outputs, the fact that they generate an .exe file
  • java_binary:
    • Document that deploy jars are self-contained and can be executed with java -jar foo_deploy.jar
    • Do not hardcode the JVM's path into the .exe files
  • Runfiles manifest:
    • Review contents of runfiles manifest for data-less java_binaries: probably doesn't need to contain things like the JDK
    • The $0.exe.runfiles directory's presence with just a runfiles manifest is weird, not documented anywhere. Consider removing this runfiles directory and just keep the $0.runfiles_manifest file.

Update(2018-07-03):

@laszlocsomor
Copy link
Contributor Author

laszlocsomor commented May 24, 2018

/cc @meteorcloudy @dslomov @ulfjack

@meteorcloudy meteorcloudy self-assigned this May 24, 2018
@laszlocsomor
Copy link
Contributor Author

Update(2018-07-03):

@meteorcloudy
Copy link
Member

If users don't define BAZEL_VC and BAZEL_VS, Bazel will detect VC installation on the machine, if not found a fake crosstool will be generated. So I guess they are not mandatory, are they?

@laszlocsomor
Copy link
Contributor Author

I have a Windows VM on which the auto-detection does not find VC, and I have to manually set the envvar.

@meteorcloudy
Copy link
Member

Just tested on the VM with 0.15.0. If I build a sh_binary, it worked without setting BAZEL_VC or BAZEL_VS. If I build a cc_binary, it threw an error asking me to install VC. This is working as expected.
But in both case it gives some warning about setting BAZEL_VC, I guess that what we should improve?

pcloudy@laszlocsomor-windows-testing MSYS ~/workspace/test
$ vim BUILD

pcloudy@laszlocsomor-windows-testing MSYS ~/workspace/test
$ vim bin.sh

pcloudy@laszlocsomor-windows-testing MSYS ~/workspace/test
$ ./bazel-0.15.0-windows-x86_64.exe build :bin
Loading:
Loading: 0 packages loaded
DEBUG: C:/users/pcloudy/_bazel_pcloudy/hyl7dsma/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:115:5:
Auto-Configuration Warning: 'BAZEL_VC' is not set, start looking for the latest Visual C++ installed.
DEBUG: C:/users/pcloudy/_bazel_pcloudy/hyl7dsma/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:115:5:
Auto-Configuration Warning: Looking for VS%VERSION%COMNTOOLS environment variables, eg. VS140COMNTOOLS
DEBUG: C:/users/pcloudy/_bazel_pcloudy/hyl7dsma/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:115:5:
Auto-Configuration Warning: Looking for Visual C++ through registry
INFO: Analysed target //:bin (4 packages loaded).
INFO: Found 1 target...
[0 / 5] [-----] Writing script bin.exe
Target //:bin up-to-date:
  C:/users/pcloudy/_bazel_pcloudy/hyl7dsma/execroot/__main__/bazel-out/x64_windows-fastbuild/bin/bin
  C:/users/pcloudy/_bazel_pcloudy/hyl7dsma/execroot/__main__/bazel-out/x64_windows-fastbuild/bin/bin.exe
INFO: Elapsed time: 1.109s, Critical Path: 0.03s
INFO: 0 processes.
INFO: Build completed successfully, 5 total actions
INFO: Build completed successfully, 5 total actions

pcloudy@laszlocsomor-windows-testing MSYS ~/workspace/test
$ ./bazel-bin/bin
hallo

pcloudy@laszlocsomor-windows-testing MSYS ~/workspace/test
$ vim BUILD

pcloudy@laszlocsomor-windows-testing MSYS ~/workspace/test
$ vim bin.cc

pcloudy@laszlocsomor-windows-testing MSYS ~/workspace/test
$ ./bazel-0.15.0-windows-x86_64.exe build :bin
Loading:
Loading: 0 packages loaded
DEBUG: C:/users/pcloudy/_bazel_pcloudy/hyl7dsma/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:115:5:
Auto-Configuration Warning: 'BAZEL_VC' is not set, start looking for the latest Visual C++ installed.
DEBUG: C:/users/pcloudy/_bazel_pcloudy/hyl7dsma/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:115:5:
Auto-Configuration Warning: Looking for VS%VERSION%COMNTOOLS environment variables, eg. VS140COMNTOOLS
DEBUG: C:/users/pcloudy/_bazel_pcloudy/hyl7dsma/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:115:5:
Auto-Configuration Warning: Looking for Visual C++ through registry
INFO: Analysed target //:bin (3 packages loaded).
INFO: Found 1 target...
[0 / 4] [-----] BazelWorkspaceStatusAction stable-status.txt
ERROR: C:/msys64/home/pcloudy/workspace/test/BUILD:1:1: C++ compilation of rule '//:bin' failed (Exit -1)

The target you are compiling requires Visual C++ build tools.
Bazel couldn't find a valid Visual C++ build tools installation on your machine.
Please check your installation following https://docs.bazel.build/versions/master/windows.html#using

Target //:bin failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.637s, Critical Path: 0.07s
INFO: 0 processes.
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully

@laszlocsomor
Copy link
Contributor Author

Just tested on the VM with 0.15.0.

Thanks for looking into this!

If I build a sh_binary, it worked without setting BAZEL_VC or BAZEL_VS.

For me too. That is WAI.

If I build a cc_binary, it threw an error asking me to install VC. This is working as expected.

For me too, and this is my primary concern. Isn't the cc_toolchain supposed to discover where VC is installed?

But in both case it gives some warning about setting BAZEL_VC, I guess that what we should improve?

That's an annoyance because it spams the output and the yellow-colored DEBUG messages look like warnings, but this is only my secondary concern.

@meteorcloudy
Copy link
Member

Hmm, I see VS 2017 is installed on the VM, but the registry info is somehow missing. Normally, bazel should be able to detect that through registry by
reg query HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS
It worked on my workstation for VS 2017.

@laszlocsomor
Copy link
Contributor Author

Could you update cc_configure to fall back on checking the default installation path if the registry key is missing?

@meteorcloudy
Copy link
Member

meteorcloudy commented Jul 3, 2018

That's a good idea!

bazel-io pushed a commit that referenced this issue Jul 4, 2018
werkt pushed a commit to werkt/bazel that referenced this issue Aug 2, 2018
@darthbinamira
Copy link

darthbinamira commented Aug 30, 2018

Want to add one issue I've encountered while following the java tutorial on Windows 10.

  1. The bazel query command seems to only work in PowerShell. I tried running with the default cmd.exe terminal in IntelliJ and it just gives the following error:
bazel query  --nohost_deps --noimplicit_deps 'deps(//:ProjectRunner)' --output graph
ERROR: The package part of 'deps(//:ProjectRunner)' should not end in a slash
  1. The same query can't be copy-pasted due to the \ and should be written in a single line.

@meteorcloudy
Copy link
Member

@darthbinamira
Thanks for reporting the issue.
In cmd.exe, we should use double quote. And indeed, there's no need to write --output graph in a separate line. I'll fix the documentation.

@malkia
Copy link

malkia commented Jun 8, 2019

Need to verify this (I'm on my Chromebook right now), but I think under windows "bazel.exe" actually runs "java.exe" (as expected), but unlike Linux, the name still comes as "java" during "tasklist" or "pslist" (from Sys Internals). Probably all it takes to rename "java.exe" to "bazel.exe", and then it can be killed.

Again need to verify this next week, when I have windows machine again!

@laszlocsomor
Copy link
Contributor Author

True, it's "java.exe" in Task Manager.

@philwo : WDYT of renaming the embedded JDK's java.exe to bazel-server.exe or something?

@philwo
Copy link
Member

philwo commented Jun 24, 2019

Quite a hack, but yeah, why not 😅 It would get confusing if we ever used the embedded JDK to run something other than the Bazel server, but I don't think that should happen anymore (@meisterT maybe knows?).

@dslomov
Copy link
Contributor

dslomov commented Jun 24, 2019

I like this. "Java? Who is Java? I am Bazel Server!"

@meisterT
Copy link
Member

meisterT commented Jun 24, 2019

We should not run anything else than Bazel itself on the embedded JDK anymore, so feel free to rename (or symlink).

@laszlocsomor
Copy link
Contributor Author

Thanks for the feedback!
Let's rename then. (And not symlink, because that's still not supported widely enough on Windows.)

@laszlocsomor laszlocsomor added the team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website label Jul 29, 2019
@laszlocsomor
Copy link
Contributor Author

laszlocsomor commented Jul 29, 2019

Updated the OP with current status.

@laszlocsomor
Copy link
Contributor Author

Rest of the stuff won't get done before 1.0, removing tag.

@laszlocsomor laszlocsomor added P3 We're not considering working on this, but happy to review a PR. (No assignee) and removed bazel 1.0 platform: windows untriaged labels Jul 29, 2019
@ofek
Copy link

ofek commented Apr 1, 2020

Any update?

@philwo
Copy link
Member

philwo commented Apr 2, 2020

@ofek Are you looking for something specific?

Recently, we've been doing some light improvements for Bazel's Windows port, but are not prioritizing it very highly, because we feel like it's currently working well enough for the known users. But if you have concrete issues that we should address, please let me know here and I'll make sure we look at them!

@ofek
Copy link

ofek commented Apr 2, 2020

Nothing in particular, just curious if the checklist is current

@lucasjinreal
Copy link

Error in fail: BAZEL_SH environment variable is not set

I cannot bare it anymore in 2023 on windows

Copy link

Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs. If you think this issue is still relevant and should stay open, please post any comment here and the issue will no longer be marked as stale.

@github-actions github-actions bot added the stale Issues or PRs that are stale (no activity for 30 days) label Apr 10, 2024
Copy link

github-actions bot commented Jul 9, 2024

This issue has been automatically closed due to inactivity. If you're still interested in pursuing this, please post @bazelbuild/triage in a comment here and we'll take a look. Thanks!

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 9, 2024
@ofek
Copy link

ofek commented Jul 9, 2024

@bazelbuild/triage

@meteorcloudy
Copy link
Member

I think most of the points in the original issues have been fixed or obsolete. Please file new issue for specific Windows bugs. Thanks!

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 P3 We're not considering working on this, but happy to review a PR. (No assignee) stale Issues or PRs that are stale (no activity for 30 days) team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website type: process
Projects
None yet
Development

No branches or pull requests

9 participants