如何在 Mac OS 上修复 Bazel 'still trying to connect to local Bazel server'?
How to fix Bazel 'still trying to connect to local Bazel server' on Mac OS?
我在本地系统上遇到了一个问题,我无法解决。我正在使用 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 然后 sudo rm -rf /private/var/tmp/_bazel_me
(只是为了确定)修复了它。
在我的例子中(Ubuntu 20.04,bazel 作为 ONOS SDN 框架的基础),bazel 花了 90 秒从 hick-up 恢复,但随后它开始工作。耐心是补救措施 ;-)
我在本地系统上遇到了一个问题,我无法解决。我正在使用 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 然后 sudo rm -rf /private/var/tmp/_bazel_me
(只是为了确定)修复了它。
在我的例子中(Ubuntu 20.04,bazel 作为 ONOS SDN 框架的基础),bazel 花了 90 秒从 hick-up 恢复,但随后它开始工作。耐心是补救措施 ;-)