Skip to content

Use $TMPDIR for lockdir instead of hardcoded /tmp#161

Open
davidj4tech wants to merge 1 commit into
tmux-plugins:masterfrom
davidj4tech:fix-tmpdir-lockdir
Open

Use $TMPDIR for lockdir instead of hardcoded /tmp#161
davidj4tech wants to merge 1 commit into
tmux-plugins:masterfrom
davidj4tech:fix-tmpdir-lockdir

Conversation

@davidj4tech

Copy link
Copy Markdown

The autosave lockdir prefix in scripts/continuum_save.sh is hardcoded to /tmp/. On systems where /tmp is not user-writable, mkdir "$lockdir1" fails with Permission denied, acquire_lock returns 1, and autosave stops silently — no log, no status-line indication. The only outward sign is that tmux_resurrect_*.txt snapshots stop updating, even though continuum_save.sh continues to be invoked on every status-line refresh.

Where this bites

Termux on Android. /tmp is owned by the Android shell group with mode 0771:

$ ls -ld /tmp
drwxrwx--x. 2 shell shell 40 May 17 23:49 /tmp

Non-shell users (your normal Termux user is u0_a*) cannot create entries inside it. The writable tmp lives at $TMPDIR, typically /data/data/com.termux/files/usr/tmp. Same shape applies to any sandbox or container where /tmp is mounted read-only or owned by another user.

Diagnosis trace

+ local lockdir_prefix=/tmp/tmux-continuum--lock-
...
+ mkdir /tmp/tmux-continuum--lock-17790792
mkdir: cannot create directory '/tmp/tmux-continuum--lock-17790792': Permission denied
+ return 1

This has been the behavior since the lockdir code was introduced in 800488c (2019).

Fix

Use ${TMPDIR:-/tmp} so the lockdir follows the environment's notion of a writable tmp directory. Falls back to /tmp when TMPDIR is unset, preserving existing behavior on Linux and macOS.

-	local lockdir_prefix="/tmp/tmux-continuum-$(current_tmux_server_pid)-lock-"
+	local lockdir_prefix="${TMPDIR:-/tmp}/tmux-continuum-$(current_tmux_server_pid)-lock-"

Verified

On Termux (Android, Debian proot, user u0_a2):

  • Before patch: continuum_save.sh fails at mkdir, no snapshots written for days despite the script firing on every status refresh.
  • After patch: mkdir succeeds in $TMPDIR, fetch_and_run_tmux_resurrect_save_script runs, fresh tmux_resurrect_*.txt appears and the last symlink updates. Subsequent runs are correctly throttled by the existing timestamp gate.

No behavioral change on systems where TMPDIR is unset or already /tmp.

The autosave lockdir prefix is hardcoded to /tmp/, which breaks on
systems where /tmp is not user-writable. On Termux (Android), /tmp is
owned by the Android `shell` group with mode 0771, so non-shell users
cannot mkdir inside it; the writable tmp lives at $TMPDIR
(/data/data/com.termux/files/usr/tmp).

When mkdir fails there, acquire_lock returns 1, the save is skipped,
and autosave stops permanently with no log or status indication. The
only outward sign is that tmux_resurrect_*.txt snapshots stop updating
even though continuum_save.sh is still invoked on every status-line
refresh.

Use ${TMPDIR:-/tmp} so the lockdir follows the environment's notion of
a writable tmp directory. Falls back to /tmp when TMPDIR is unset,
preserving existing behavior on Linux/macOS.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants