zellij: Unable to attach to sessions over SSH
2. Issues with the Zellij UI / behavior / crash
Issue description
Currently Zellij session discovery need $XDG_RUNTIME_DIR, which is set by systemd, and may not be set when connecting over SSH https://github.com/zellij-org/zellij/discussions/3700
Minimal reproduction
- Open local session, run some commands
- Connect from remote machine over SSH
- Run
zellij attachto local session
See no content from previous commands in attached tab.
Other relevant information
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 19
Commits related to this issue
- [xdg-basedir-workarounds.fish] Try to set `$XDG_RUNTIME_DIR`. Workaround for: https://github.com/zellij-org/zellij/issues/3708 — committed to lgarron/dotfiles by lgarron 2 years ago
- [config.fish] Explicitly set `$TMPDIR\` using `mktemp` on macOS if it's not set. This is a workaround for https://github.com/zellij-org/zellij/issues/3708 in iTerm. — committed to lgarron/dotfiles by lgarron 2 years ago
- [config.fish] Explicitly set `$TMPDIR` using `mktemp` on macOS if it's not set. This is a workaround for https://github.com/zellij-org/zellij/issues/3708 in iTerm. — committed to lgarron/dotfiles by lgarron 2 years ago
- [config.fish] Try to remove `$TMPDIR` workaround for `zellij`. Rust 1.84 is out now, which hopefully fixes this. See: https://github.com/zellij-org/zellij/issues/3708 — committed to lgarron/dotfiles by lgarron 2 years ago
- Rebuild `zellij` bottles using Rust 1.85 stable `zellij` is written in Rust. Until Rust 1.85.0, Rust's [`temp_dir()`](https://doc.rust-lang.org/std/env/fn.temp_dir.html) implementation made an ass... — committed to lgarron/homebrew-core by lgarron 2 years ago
- Rebuild `zellij` bottles using Rust 1.85 stable `zellij` is written in Rust. Until Rust 1.85.0, Rust's [`temp_dir()`](https://doc.rust-lang.org/std/env/fn.temp_dir.html) implementation made an assum... — committed to lgarron/homebrew-core by lgarron 2 years ago
- zellij: revision bump Rebuild `zellij` bottles using Rust 1.85 stable `zellij` is written in Rust. Until Rust 1.85.0, Rust's [`temp_dir()`](https://doc.rust-lang.org/std/env/fn.temp_dir.html) imple... — committed to lgarron/homebrew-core by lgarron 2 years ago
Just wanted to bring up that XDG_RUNTIME_DIR isn’t guaranteed to persist if user logs out, according to the specification iirc the sticky bit that Zellij uses to “save” the socket from getting deleted actually only protects it from optional wipe that can be set to happen every 6 hours. Tmux doesn’t use XDG_RUNTIME_DIR for this and unless the intended behaviour of Zellij is to create a dangling unreachable session if user only logs in over ssh, starts Zellij session, disconnects from the session and then from ssh, I feel like the socked should be moved to a location that doesn’t potentially get wiped in those situations.
Yeah, I think this is it.
If we let ⭐️ mean
/var/folders/0j/2q1m_86950q5gjl4b1mt62f40000gn/Tin my case, then:mktempon commandline$TMPDIRon commandlinezellijTerminal.appiTerm.app/tmp/I can confirm that a connection over SSH has no issue connecting to the same sessions as a shell in
Terminal.app. So the issues appear to be:zellijis not actually using$XDG_RUNTIME_DIRat all.iTerm.app, presumably because$TMPDIRis not set.Unfortunately:
set -x TMPDIR (dirname (dirname (mktemp)))does not fix the issue in iTerm[^1], even if Ikillall zellijto reset memory state.$XDG_RUNTIME_DIRthat certainly doesn’t solve the problem for other iTerm users.The only solutions that would work out of the box are:
/tmp/as the temp dir root, at least on macOS. This is less safe.mktempcommand gets the correct path even when$TMPDIRis not set, this implies the “correct” temp dir should be possible to access in a minimally hacky way.I would appreciate input from the maintainers about how to handle this in a PR.
[^1]: EDIT: Turns out
set -x TMPDIR (dirname (mktemp))does work.