简体   繁体   中英

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 --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 (只是为了确定)修复了它。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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