ITADN

tmux not being detected on Windows (MSYS2)

#4044ClosedHaha64142 创建于 2026-06-15
invalid
H
Haha64142commented
### What system are you running Yazi on? Windows ### What terminal are you running Yazi in? tmux 3.6a inside of mintty 3.8.3 ### `ya env` output ```Shell Yazi Version: 26.5.6 (f1e93d7f 2026-06-15) Debug : true Triple : x86_64-pc-windows-gnu (windows-x86_64) Rustc : 1.96.0 (ac68faa2 2026-05-25) Backtrace: None Ya Version: 26.5.6 (f1e93d7f 2026-06-15) Debug : true Triple : x86_64-pc-windows-gnu (windows-x86_64) Rustc : 1.96.0 (ac68faa2 2026-05-25) Config Init : C:\Users\Haha\AppData\Roaming\yazi\config\init.lua (The system cannot find the path specified. (os error 3)) Yazi : C:\Users\Haha\AppData\Roaming\yazi\config\yazi.toml (The system cannot find the path specified. (os error 3)) Keymap : C:\Users\Haha\AppData\Roaming\yazi\config\keymap.toml (The system cannot find the path specified. (os error 3)) Theme : C:\Users\Haha\AppData\Roaming\yazi\config\theme.toml (The system cannot find the path specified. (os error 3)) VFS : C:\Users\Haha\AppData\Roaming\yazi\config\vfs.toml (The system cannot find the path specified. (os error 3)) Package : C:\Users\Haha\AppData\Roaming\yazi\config\package.toml (The system cannot find the path specified. (os error 3)) Dark/light flavor: ArcSwapAny("") / ArcSwapAny("") Emulator TERM : Some("tmux-256color") TERM_PROGRAM : Some("tmux") TERM_PROGRAM_VERSION: Some("3.6a") Brand.from_env : None Emulator.detect : Emulator { kind: Right(Unknown { kgp: false, sixel: false }), version: "", light: false, csi_16t: (0, 0), force_16t: false } Adapter Adapter.matches : Chafa Dimension.available: Dimension { cols: 271, rows: 70, width: 0, height: 0 } Desktop XDG_SESSION_TYPE : None WAYLAND_DISPLAY : None DISPLAY : None NIRI_SOCKET : None SWAYSOCK : None HYPRLAND_INSTANCE_SIGNATURE: None WAYFIRE_SOCKET : None SSH shared.in_ssh_connection: false WSL WSL: false Variables SHELL : Some("C:\\msys64\\usr\\bin\\bash.exe") EDITOR : None VISUAL : None YAZI_FILE_ONE : None YAZI_CONFIG_HOME : None YAZI_ZOXIDE_OPTS : None SSH_AUTH_SOCK : None FZF_DEFAULT_OPTS : None FZF_DEFAULT_COMMAND: None Text Opener default : Some(OpenerRule { id: Id(4), run: NonEmptyString("code %s"), block: false, orphan: true, desc: "code", for: Windows, spread: true }) block-create: Some(OpenerRule { id: Id(5), run: NonEmptyString("code -w %s"), block: true, orphan: false, desc: "code (block)", for: Windows, spread: true }) block-rename: Some(OpenerRule { id: Id(5), run: NonEmptyString("code -w %s"), block: true, orphan: false, desc: "code (block)", for: Windows, spread: true }) Multiplexers TMUX : false tmux version : tmux 3.6a tmux build flags : enable-sixel=Unknown ZELLIJ_SESSION_NAME: None Zellij version : program not found Dependencies file : 5.48 ueberzugpp : program not found ffmpeg/ffprobe: program not found / program not found pdftoppm : program not found magick : program not found fzf : program not found fd/fdfind : program not found / program not found rg : program not found chafa : program not found zoxide : program not found 7zz/7z : program not found / program not found resvg : program not found jq : program not found Clipboard wl-copy/paste: program not found / program not found xclip : program not found xsel : program not found Routine `file -bL --mime-type`: text/plain ``` ### Describe the bug Tmux isnt being detected. This means it also isnt able to detect sixel support or the terminal its running in. I believe it has something to do with the `Emulator::read_until_da1` function. ### Minimal reproducer 1. install [msys2](https://www.msys2.org/) 2. open msys2 ucrt64 3. run `pacman -S tmux mingw-w64-ucrt-x86_64-yazi` 4. run `tmux` 5. run `yazi --debug` or `ya env` ### Anything else? Here's what I've discovered so far: I added a breakpoint at yazi-emulator/src/emulator.rs:58 ```rust let resp = Self::read_until_da1(); Mux::tmux_drain()?; // Breakpoint here let kind = if let Some(b) = Brand::from_csi(&resp).or(resort) { Either::Left(b) ``` When it hit the breakpoint I outputted the `resp` variable. On fedora this is what it was: ``` \033P>|tmux 3.6b\033\\\033[6;20;9t\033]11;rgb:0000/0000/0000\a\033[?1;2;4c ``` On windows, this is what it was: ``` b'\x1b[?61;6;7;21;22;23;24;28;32;42c' ``` --- I noticed the windows response didn't have any of the other terminal responses so I forced the `read_until_da1` function to read the whole terminal response using this patch: ``` diff --git a/yazi-emulator/src/emulator.rs b/yazi-emulator/src/emulator.rs index 4fa69927..08f86f98 100644 --- a/yazi-emulator/src/emulator.rs +++ b/yazi-emulator/src/emulator.rs @@ -108,7 +108,7 @@ impl Emulator { let now = std::time::Instant::now(); let h = tokio::spawn(Self::error_to_user()); - let (buf, result) = TTY.read_until(Duration::from_millis(1000), |b, buf| { + let (buf, result) = TTY.read_until(Duration::from_millis(300), |b, buf| { b == b'c' && buf.contains(&0x1b) && buf.rsplitn(2, |&b| b == 0x1b).next().is_some_and(|s| s.starts_with(b"[?")) diff --git a/yazi-tty/src/tty.rs b/yazi-tty/src/tty.rs index d55f5118..19675214 100644 --- a/yazi-tty/src/tty.rs +++ b/yazi-tty/src/tty.rs @@ -39,7 +39,7 @@ impl Tty { let mut stdin = self.stdin.lock(); loop { if now.elapsed() > timeout { - return Err(Error::from(ErrorKind::TimedOut)); + break; } else if !stdin.poll(Duration::from_millis(30))? { continue; } @@ -49,7 +49,7 @@ impl Tty { buf.push(b[0]); if predicate(b[0], &buf) { - break; + // break; } } Ok(()) ``` After rebuilding on windows with those patches, the `resp` variable became: ``` b'\x1b[?61;6;7;21;22;23;24;28;32;42c\x1bP>|tmux 3.6a\x1b\\\x1b[6;20;9t' ``` --- This is where the requests are sent: ```rust writef!( TTY.writer(), "{SaveCursorPos}{}{}{}{}{}{RestoreCursorPos}", If(resort.is_none(), Mux::wrap(KittyGraphicsQuery)), Mux::wrap(RequestXtVersion), RequestCellPixelSize, RequestBgColor, Mux::wrap(RequestDA1), )?; ``` The patched windows response isn't the same order as the request. I believe this is what is causing tmux to not be detected. ### Checklist - [x] I tried the [latest nightly build](https://yazi-rs.github.io/docs/installation#binaries), and the issue is still reproducible - [x] I updated the environment information (`ya env`) field to the nightly that I tried - [x] I can reproduce it after disabling all custom configs/plugins (`mv ~/.config/yazi ~/.config/yazi-backup`)
关闭于 2026-06-19 13 条评论