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

Windows: building C++ hello-world requires local_config_sh #6498

Closed
meteorcloudy opened this issue Oct 24, 2018 · 3 comments
Closed

Windows: building C++ hello-world requires local_config_sh #6498

meteorcloudy opened this issue Oct 24, 2018 · 3 comments
Assignees
Labels
area-Windows Windows-specific issues and feature requests P1 I'll work on this now. (Assignee required) team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website type: bug

Comments

@meteorcloudy
Copy link
Member

To reproduce

  1. Apply Windows: windows_cc_configure.bzl no longer fails when BAZEL_SH isn't set #6497
  2. Comment out the line
    DetectBashOrDie();
  3. Build Bazel
  4. Unset BAZEL_SH (with set BAZEL_SH=)
  5. Run bazel build examples/cpp:hello-world
pcloudy@pcloudy0-w MSYS ~/workspace/my_tests/bazel
$ bazel build examples/cpp:hello-world
WARNING: The following rc files are no longer being read, please transfer their contents or import their path into one of the standard rc files:
C:\Users\pcloudy/.bazelrc
INFO: Invocation ID: eff13024-3f65-4713-8ef2-108ea283b391
INFO: Build options have changed, discarding analysis cache.
ERROR: While resolving toolchains for target //examples/cpp:hello-world: invalid registered toolchain '@local_config_sh//:local_sh_toolchain': no such package '@local_config_sh//': type 'path' has no method startswith(string)
ERROR: Analysis of target '//examples/cpp:hello-world' failed; build aborted: invalid registered toolchain '@local_config_sh//:local_sh_toolchain': no such package '@local_config_sh//': type 'path' has no method startswith(string)
INFO: Elapsed time: 0.223s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 18 targets configured)
    Fetching @local_config_sh; fetching...
@meteorcloudy meteorcloudy added type: bug P2 We'll consider working on this in future. (Assignee optional) area-Windows Windows-specific issues and feature requests labels Oct 24, 2018
@meteorcloudy meteorcloudy changed the title Windows: building hello-world requires local_config_sh Windows: building C++ hello-world requires local_config_sh Oct 24, 2018
@laszlocsomor laszlocsomor added P1 I'll work on this now. (Assignee required) and removed P2 We'll consider working on this in future. (Assignee optional) labels Oct 24, 2018
@laszlocsomor
Copy link
Contributor

Thanks for filing this! It's a bad first-time user experience, so I'm linking #5254.

@laszlocsomor
Copy link
Contributor

I can't seem to repro this :S

Here's my source tree:

$ pwd
/c/src/bazel

$ git log -2 --oneline
eb75c814b1 (HEAD) Adrress review comments
983d96d8ec Add msys_gcc_installation_error.bat

And the diff:

diff --git a/src/main/cpp/blaze.cc b/src/main/cpp/blaze.cc
index 9a3396cbd5..df8c455ca7 100644
--- a/src/main/cpp/blaze.cc
+++ b/src/main/cpp/blaze.cc
@@ -1540,7 +1540,7 @@ int Main(int argc, const char *argv[], WorkspaceLayout *workspace_layout,
   // Must be done before command line parsing.
   // ParseOptions already populate --client_env, so detect bash before it
   // happens.
-  DetectBashOrDie();
+  // DetectBashOrDie();

   globals->binary_path = CheckAndGetBinaryPath(argv[0]);
   ParseOptions(argc, argv);

I built Bazel here, then used it like so:

C:\src\bazel>set
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_152
SystemDrive=C:
SystemRoot=C:\WINDOWS

C:\src\bazel>c:\_bazel\o2bbs3hu\execroot\io_bazel\bazel-out\x64_windows-fastbuild\bin\src\bazel.exe --output_user_root=c:\tmp1 build //examples/cpp:hello-world
WARNING: The following rc files are no longer being read, please transfer their contents or import their path into one of the standard rc files:
C:\Users\laszlocsomor/.bazelrc
Starting local Bazel server and connecting to it...
INFO: Invocation ID: 368e5bae-ea5f-4527-9d75-12fcec5b3c81
DEBUG: C:/tmp1/o2bbs3hu/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:115:5:
Auto-Configuration Warning: 'PROGRAMFILES(X86)' environment variable is not set, using 'C:\Program Files (x86)' as default
DEBUG: C:/tmp1/o2bbs3hu/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:115:5:
Auto-Configuration Warning: 'TMP' environment variable is not set, using 'C:\Windows\Temp' as default
INFO: Analysed target //examples/cpp:hello-world (7 packages loaded, 71 targets configured).
INFO: Found 1 target...
Target //examples/cpp:hello-world up-to-date:
  C:/tmp1/o2bbs3hu/execroot/io_bazel/bazel-out/x64_windows-fastbuild/bin/examples/cpp/hello-world.exe
INFO: Elapsed time: 14.219s, Critical Path: 3.11s
INFO: 4 processes: 4 local.
INFO: Build completed successfully, 9 total actions

@meteorcloudy
Copy link
Member Author

I tried again and I am still able to reproduce this issue.
Since #6497 is merged, can you sync to BAZEL HEAD and retry?

laszlocsomor added a commit to laszlocsomor/bazel that referenced this issue Oct 25, 2018
When DetectBashOrDie [1] is commented out from
src/main/cpp/blaze.cc, and BAZEL_SH is unset,
and PATH is set and "bash" is found on the PATH,
then sh_configure successfully finds bash using
repository_ctx.which, and this method returns a
"path" object.

The code used to believe this was a string, and
called a string method on it, causing a runtime
error.

[1] https://github.com/bazelbuild/bazel/blob/2fda17d46088f2bb07b049fa35759002ea1dd5db/src/main/cpp/blaze.cc#L1543

Fixes bazelbuild#6498

Change-Id: I07fd36fd6c6e8433257b0394f1fc776bbe3e6928
@philwo philwo added the team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website label Jun 15, 2020
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 P1 I'll work on this now. (Assignee required) team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website type: bug
Projects
None yet
Development

No branches or pull requests

3 participants