简体   繁体   English

如何修复 Mac OS 上的 Bazel“仍在尝试连接到本地 Bazel 服务器”?

[英]How to fix Bazel 'still trying to connect to local Bazel server' on Mac OS?

I am experiencing an issue on my local system, which I cannot figure out to solve.我在本地系统上遇到了一个我无法解决的问题。 I am using Bazel and it looks like the Bazel server process is being blocked by some Mac OS security setting from opening ports.我正在使用 Bazel,看起来 Bazel 服务器进程被某些 Mac OS 安全设置阻止,无法打开端口。

> bazel --version
bazel 4.2.1

> bazel info
Starting local Bazel server and connecting to it...
... still trying to connect to local Bazel server after 20 seconds ...
... still trying to connect to local Bazel server after 40 seconds ...
... still trying to connect to local Bazel server after 60 seconds ...
... still trying to connect to local Bazel server after 80 seconds ...
... still trying to connect to local Bazel server after 100 seconds ...
FATAL: couldn't connect to server (212) after 120 seconds.
> bazel --batch info
bazel-bin: /private/var/tmp/_bazel_me/hash/execroot/jdt_java_toolchain_ws/bazel-out/darwin-fastbuild/bin
bazel-genfiles: /private/var/tmp/_bazel_me/hash/execroot/jdt_java_toolchain_ws/bazel-out/darwin-fastbuild/bin
bazel-testlogs: /private/var/tmp/_bazel_me/hash/execroot/jdt_java_toolchain_ws/bazel-out/darwin-fastbuild/testlogs
character-encoding: file.encoding = ISO-8859-1, defaultCharset = ISO-8859-1
command_log: /private/var/tmp/_bazel_me/hash/command.log
committed-heap-size: 2147MB
execution_root: /private/var/tmp/_bazel_me/hash/execroot/jdt_java_toolchain_ws
gc-count: 2
gc-time: 9ms
install_base: /var/tmp/_bazel_me/install/anotherhash
java-home: /private/var/tmp/_bazel_me/install/anotherhash/embedded_tools/jdk
java-runtime: OpenJDK Runtime Environment (build 11.0.6+10-LTS) by Azul Systems, Inc.
java-vm: OpenJDK 64-Bit Server VM (build 11.0.6+10-LTS, mixed mode) by Azul Systems, Inc.
max-heap-size: 32178MB
output_base: /private/var/tmp/_bazel_me/hash
output_path: /private/var/tmp/_bazel_me/hash/execroot/jdt_java_toolchain_ws/bazel-out
package_path: %workspace%
release: release 4.2.1
repository_cache: /var/tmp/_bazel_me/cache/repos/v1
server_log: /private/var/tmp/_bazel_me/hash/java.log.gwagenk-wsm44cr.me.log.java.20211014-133941.786
server_pid: 786
used-heap-size: 68MB
workspace: /Users/me/dev/bazel/jdt-java-toolchain

I can see the server process being there:我可以看到服务器进程在那里:

> ps aux | grep bazel
me       212   ... bazel(jdt-java-toolchain) 
  -XX:+HeapDumpOnOutOfMemoryError 
  -XX:HeapDumpPath=/private/var/tmp/_bazel_me/hash 
  --add-opens=java.base/java.nio=ALL-UNNAMED 
  --add-opens=java.base/java.lang=ALL-UNNAMED 
  -Xverify:none 
  -Djava.util.logging.config.file=/private/var/tmp/_bazel_me/hash/javalog.properties 
  -Dcom.google.devtools.build.lib.util.LogHandlerQuerier.class=com.google.devtools.build.lib.util.SimpleLogHandler$HandlerQuerier 
  -XX:-MaxFDLimit 
  -Djava.library.path=/var/tmp/_bazel_me/install/anotherhash/embedded_tools/jdk/lib/jli:/var/tmp/_bazel_me/install/anotherhash/embedded_tools/jdk/lib:/var/tmp/_bazel_me/install/anotherhash/embedded_tools/jdk/lib/server:/var/tmp/_bazel_me/install/anotherhash/embedded_tools/tools/objc:/var/tmp/_bazel_me/install/anotherhash/ 
  -Dfile.encoding=ISO-8859-1 
  -jar /var/tmp/_bazel_me/install/anotherhash/A-server.jar 
  --max_idle_secs=10800 
  --noshutdown_on_low_sys_mem 
  --connect_timeout_secs=30 
  --output_user_root=/var/tmp/_bazel_me 
  --install_base=/var/tmp/_bazel_me/install/anotherhash 
  --install_md5=anotherhash 
  --output_base=/private/var/tmp/_bazel_me/hash 
  --workspace_directory=/Users/me/dev/bazel/jdt-java-toolchain 
  --default_system_javabase=/Library/Java/JavaVirtualMachines/openjdk_11.0......jdk/Contents/Home 
  --failure_detail_out=/private/var/tmp/_bazel_me/hash/failure_detail.rawproto 
  --expand_configs_in_place 
  --idle_server_tasks 
  --write_command_log 
  --nowatchfs 
  --nofatal_event_bus_exceptions 
  --nowindows_enable_symlinks 
  --client_debug=false 
  --product_name=Bazel 
  --noincompatible_enable_execution_transition 
  --option_sources=

It does look like the port cannot be reached:看起来确实无法到达该端口:

> cat /private/var/tmp/_bazel_me/hash/server/command_port 
[::1]:59769⏎                                                                                                                                                                                                

> nc -vz ::1 59769
nc: connectx to ::1 port 59769 (tcp) failed: Operation timed out

This used to work.这曾经奏效。 There have been a couple security updates in the last weeks and I am not sure when it and what broke.过去几周进行了几次安全更新,我不确定它何时发生以及发生了什么问题。

The firewall is turned on and I'm unable to turn it off.防火墙已打开,但我无法将其关闭。 Mac OS 防火墙设置

令人尴尬的是,重新启动 Mac,然后sudo rm -rf /private/var/tmp/_bazel_me (只是为了确定)修复了它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM