Skip to content

fix(bootstrap): set TMPDIR for template tasks so mktemp works on Windows - #1095

Open
armaan4658 wants to merge 1 commit into
livekit:mainfrom
armaan4658:fix/windows-tmpdir-911
Open

armaan4658 wants to merge 1 commit into
livekit:mainfrom
armaan4658:fix/windows-tmpdir-911

Conversation

@armaan4658

Copy link
Copy Markdown

Fixes the post_create failure in #911.

Problem

On Windows, lk app create --template agent-starter-python prints "Your agent has been created!", then set_agent_name_if_present fails with:

coreutils: open /tmp\2013691747: The system cannot find the path specified.

As a result, agent_name in src/agent.py is never rewritten.

Cause

On Windows, task runs core utils in-process (useGoCoreUtils defaults to true there). It does this through mvdan.cc/sh/moreinterp/coreutils, which uses u-root's mktemp. In u-root v0.16.0, mktemp uses $TMPDIR and otherwise falls back to a hardcoded "/tmp". Windows doesn't set TMPDIR, so the result is /tmp\NNN, which isn't a valid absolute path. u-root has fixed this on main but hasn't released it yet.

Fix

In NewTaskExecutor, if TMPDIR is unset, set it to os.TempDir(). All three task entry points in cmd/lk/app.go go through this function. On macOS and Linux, os.TempDir() already returns $TMPDIR or /tmp, and task uses the system mktemp there anyway, so behaviour doesn't change.

Test

TestTaskMktempWithoutTMPDIR unsets TMPDIR and runs the same mktemp / >> "$tmp" pattern the template uses. It checks that the temp path is absolute and writable. Asserting the path is absolute matters: if \tmp happens to exist on the current drive, /tmp\NNN resolves and the bug is hidden.

On Windows 11 / Go 1.27.3, go test ./pkg/bootstrap/:

  • without the fix: task: Failed to run task "mk": exit status 1
  • with the fix: passes

Not in scope

On Windows, task runs core utils in-process via u-root, whose mktemp
falls back to a hardcoded /tmp when TMPDIR is unset. That produces
paths like /tmp\NNN, so the agent-starter-python post_create step
fails to write its temp file and never renames the agent.

Default TMPDIR to os.TempDir() in NewTaskExecutor when it is unset.
macOS and Linux are unaffected.

Fixes livekit#911
@boks1971
boks1971 requested a review from rektdeckard November 16, 2026 11:47

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

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