[Windows] PersistentPty spawns MSYS2 zsh without -l (non-login), missing /usr/bin in PATH
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ó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 22/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- typescript, zsh
- Lĩnh vực
- cli
Hướng nghiên cứu
Start in packages/core/src/persistent-pty/index.ts around the PersistentPty.create call, which forwards args: [] to the daemon, and compare it with the -l handling in packages/core/src/pty.ts. Check whether ShellSelect.login should apply on this path, and reproduce the non-login zsh PATH problem in an MSYS2 session. Done means the built-in terminal starts as a login shell with the MSYS2 PATH intact, and the maintainers have confirmed whether omitting -l was intentional.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
On Windows 10, after starting MSYS2 zsh via C:\msys64\msys2_shell.cmd -defterm -here -no-start -ucrt64 -shell zsh -use-full-path and running opencode or opencode pair inside it, opening the built-in terminal (via /terminal in the TUI or the sidebar Terminal in the Web UI) spawns a zsh process that still receives SHELL and MSYSTEM, but starts in non-login mode (! -o login) and is missing /ucrt64/bin, /usr/bin, and /bin from PATH. As a result, tools and prompt themes that rely on MSYS2's /etc/profile PATH setup fail to initialize (for example, Powerlevel10k reports gitstatus failed to initialize):
Terminal error output (without the ~/.zshenv workaround)
[WARNING]: Console output during zsh initialization detected.
...
[ERROR]: gitstatus failed to initialize.
Add the following parameter to ~/.zshrc for extra diagnostics on error:
GITSTATUS_LOG_LEVEL=DEBUG
Restart Zsh to retry gitstatus initialization:
exec zsh
Adding the following workaround in ~/.zshenv resolves the terminal issue (checking -o interactive && ! -o login confirms that the built-in terminal starts zsh as interactive non-login):
if [[ -o interactive && ! -o login && ":$PATH:" != *":/usr/bin:"* ]]; then
export MSYSTEM="${MSYSTEM:-UCRT64}"
typeset -U path
if [[ "$MSYSTEM" == MSYS ]]; then
path=(/usr/local/bin /usr/bin /bin $path)
else
path=(/${MSYSTEM:l}/bin /usr/local/bin /usr/bin /bin $path)
fi
fi
Also worth noting: in opencode pair (Web) sessions, because the background service runs independently of the launching terminal and the model shell tool executes zsh non-interactively (zsh +o nomatch -c), it likewise does not pick up MSYS2 /etc/profile, ~/.zprofile, or ~/.zshrc environment setup (related: #51051, #57310).
Source code notes (as of v2.3.2)
- Missing
-linPersistentPty.create:Pty.createinpackages/core/src/pty.ts(L168–169) checksShellSelect.login(command)and automatically appends"-l"for shells likebashandzsh. However, both the TUI/terminal(packages/tui/src/context/session-terminals.tsx, L104–110) and the Web sidebar terminal (packages/gui-plugins/src/terminal/model.ts, L327–337) go throughPersistentPty.create(packages/core/src/persistent-pty/index.ts, L251–263), which forwards the client-providedargs: []directly to theopencode-ptydaemon (and readsShellSelect.environment()instead ofconfig.shell, see #51051). As a result, MSYS2zshskips/etc/profileand loses/ucrt64/bin,/usr/bin, and/binfromPATH. I'm not completely sure whether omitting-linPersistentPtyis intentional or a bug. - POSIX path lookup on Windows:
full()andexecutable()inpackages/core/src/shell/select.tscurrently only map/.../bashpaths togitbash()on Windows—when encountering a drive-less POSIX path like/usr/bin/zsh.exewhose nativestat()fails, they do not fall back to looking up the basename onPATH. - Non-interactive
shelltool inopencode pair:ShellSelect.args()runszshwith["+o", "nomatch", "-c", command], which in background-service-backedopencode pairsessions only inherits the service's own environment and~/.zshenv.
Plugins
None
OpenCode version
v2.3.2
Steps to reproduce
- On Windows 10, start MSYS2
zshusingC:\msys64\msys2_shell.cmd -defterm -here -no-start -ucrt64 -shell zsh -use-full-path(without manually patchingPATHin~/.zshenv). - Run
opencodeoropencode pairinside thatzshsession. - Open the built-in terminal (
/terminalin TUI, or the sidebar Terminal in the Web UI). - In the new built-in terminal, check login mode and
PATH:
Observe that[[ -o login ]] && echo login || echo non-login echo "$PATH"zshlaunches asnon-loginwith/ucrt64/bin,/usr/bin, and/binmissing fromPATH(and prompt themes like Powerlevel10k fail withgitstatus failed to initialize).
Screenshot
No response
Operating System
Microsoft Windows 10 Pro (10.0.19045 Build 19045)
Terminal
WezTerm (MSYS2 UCRT64 zsh) / OpenCode TUI & Web Terminal
- Ngôn ngữ chính
- TypeScript
- Star
- 230k
- Fork
- 31.3k
- Merge trung bình
- 5 giờ 32 phút
- Pull request đã merge (30 ngày)
- 453
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của anomalyco/opencode
-
area/desktop platform/macos status/repro-plausible type/bug version/v2
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
anomalyco/opencode#67064 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 82/100
anomalyco/opencode#67009 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area/web type/feature version/v2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
anomalyco/opencode#67001 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
skills: a Claude-compatible SKILL.md that fails to parse is dropped without any logCó thể đã có người làm @liwenjie200543 đã nhận 2 ngày trước. Đang mởarea/plugins platform/linux reproduced type/bug version/v2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
anomalyco/opencode#66970 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
tui: Mermaid renderer displays <b>/<strong> tags literally and ignores \n line breaksCó thể đã có người làm @argszero đã nhận 2 ngày trước. Đang mởarea/tui platform/wsl status/repro-simulated type/bug version/v2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
anomalyco/opencode#66773 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của anomalyco/opencode
Issue tương tự
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
ci
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
ClickHouse/clickhouse-js#1248 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
E2E: Darlehen-Test wartet auf die gebuchte Auszahlung, bevor er zur Liquiditätsvorschau wechseltĐang mởtechnik
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
SR5-FoundryVTT/SR5-FoundryVTT#2162 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
AhmedNAgy25/analysor#25 ·
Maintainer thường phản hồi trong vòng 1 ngày