SSH device hosts on macOS never give avdmanager Android Studio's bundled JDK, so emulators can't boot

Đang mở Phù hợp với người mới
#45,611 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
79/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
android, javascript, macos, typescript
Lĩnh vực
devtools

Hướng nghiên cứu

Đọc apps/server/src/device/sshDeviceScript.ts, đặc biệt là khối remoteDeviceEnvironment ở dòng 13–17, và theo dõi cách nó phát hiện Java cũng như kiểm tra các đường dẫn JDK của Android Studio. Tái hiện các trường hợp được báo cáo bằng /bin/sh, PATH đã nêu và các cấu trúc JDK thay thế được liệt kê. Hoàn tất khi fallback tìm được JDK đi kèm trên macOS dù có /usr/bin/java, và trình giả lập có thể hoàn tất việc chờ thiết bị.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

via-triage
What happened

On a Mac used as an SSH device host, where the only Java is the JDK bundled with Android Studio (no system JDK, no JAVA_HOME in the shell profile), Android emulators can't be booted from the Device panel. The device hub runs avdmanager, a Java program, during every boot, and the SSH host's Java fallback never hands it Android Studio's JDK.

Diagnosis

remoteDeviceEnvironment in apps/server/src/device/sshDeviceScript.ts (lines 13-17) has a fallback for this, but on macOS it never works, for two reasons:

  1. It runs only when command -v java fails. macOS always has /usr/bin/java, a launcher that exits with "Unable to locate a Java Runtime" when no JDK is installed, so command -v java succeeds and the fallback is skipped.
  2. Its macOS candidates are Android Studio.app/Contents/jbr, but Android Studio keeps its JDK one level deeper. In the 2026.2.2.9 macOS download, Contents/jbr holds only Contents/, and Java is at Contents/jbr/Contents/Home/bin/java. So even when the fallback runs, [ -x "$device_java_home/bin/java" ] finds nothing.

With expo-device-hub 0.26.1, the hub launches the emulator, then waits for it with listDevices, which runs avdmanager list avd first. Without Java that fails, so the boot ends with "Failed while waiting for to come online".

Linux hosts aren't affected: there's no launcher stub, and Android Studio's Linux JDK is at android-studio/jbr/bin/java, which the script checks.

Steps to reproduce

On a real Mac with no JDK installed, I ran the remoteDeviceEnvironment block from main with /bin/sh, HOME set to a temp folder, and a stand-in java at $HOME/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java:

  1. PATH=/usr/bin:/bin: JAVA_HOME stays empty, because command -v java finds the /usr/bin/java launcher.
  2. PATH=/bin (launcher hidden): JAVA_HOME still stays empty, because the loop looks for Contents/jbr/bin/java.
  3. Control: with the stand-in moved to Contents/jbr/bin/java and PATH=/bin, JAVA_HOME is set.

End to end (not run here): add a Mac that has Android Studio, the SDK and an AVD, but no other JDK, as an SSH device host, then start the AVD from the Device panel.

Version

main at ec111d006e (these lines are unchanged since #10856)

Environment

SSH device host: macOS 27.2.1, arm64, no JDK installed. Android Studio layout checked in Google's 2026.2.2.9 macOS DMG. T3 server: Linux.

Evidence
$ /usr/libexec/java_home
The operation couldn’t be completed. Unable to locate a Java Runtime.

1) PATH=/usr/bin:/bin
  JAVA_HOME=[]  command -v java -> /usr/bin/java
2) PATH=/bin
  JAVA_HOME=[]  command -v java -> none
3) control, java at Contents/jbr/bin/java, PATH=/bin
  JAVA_HOME=[<tmp>/home-b/Applications/Android Studio.app/Contents/jbr]
Related issues

#38921 is the same no-Java setup on a local Mac (it hid physical devices; #38954 fixed listing). This is the SSH host's own fallback, so not a duplicate. Open PR #36709 rewrites this script block but not its Java lines.

Fix applied or workaround

Nothing was changed on the Mac. Untested: setting JAVA_HOME to /Applications/Android Studio.app/Contents/jbr/Contents/Home in a file the SSH session reads, such as ~/.zshenv, or installing a JDK system-wide, should avoid it.

Filed by

Claude Opus 5.5 (Claude Code), on Jackson's behalf. Followed T3's triage playbook and this template; the t3 triage command itself wasn't run. Reproduced at script level on a real Mac against main ec111d006e.

_Claude Opus 5.5, an AI agent, on Jackson's behalf

Ngôn ngữ chính
TypeScript
Star
24.8k
Fork
6.4k
Merge trung bình
59 phút
Pull request đã merge (30 ngày)
613

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của pingdotgg/t3code

Tất cả issue của pingdotgg/t3code

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.