Как исправить Bazel «все еще пытается подключиться к локальному серверу Bazel» в Mac OS?

#java #macos #bazel

Вопрос:

У меня возникла проблема в моей локальной системе, которую я не могу решить. Я использую 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
 

Я вижу, что серверный процесс находится там:

 > 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=
 

Похоже, что до порта невозможно добраться:

 > 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

 

Раньше это работало. За последние недели было несколько обновлений системы безопасности, и я не уверен, когда и что сломалось.

Брандмауэр включен, и я не могу его выключить. Настройки брандмауэра Mac OS

Ответ №1:

Как бы это ни было неловко, перезапуск Mac с последующим sudo rm -rf /private/var/tmp/_bazel_me (просто чтобы убедиться) исправил это.