Repository navigation
fix(bootstrap): set TMPDIR for template tasks so mktemp works on Windows - #1095
Open
armaan4658 wants to merge 1 commit into
Open
armaan4658 wants to merge 1 commit into
armaan4658 wants to merge 1 commit into
Conversation
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
rektdeckard
approved these changes
Nov 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the post_create failure in #911.
Problem
On Windows,
lk app create --template agent-starter-pythonprints "Your agent has been created!", thenset_agent_name_if_presentfails with:As a result,
agent_nameinsrc/agent.pyis never rewritten.Cause
On Windows, task runs core utils in-process (
useGoCoreUtilsdefaults to true there). It does this throughmvdan.cc/sh/moreinterp/coreutils, which uses u-root'smktemp. In u-root v0.16.0,mktempuses$TMPDIRand otherwise falls back to a hardcoded"/tmp". Windows doesn't setTMPDIR, 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, ifTMPDIRis unset, set it toos.TempDir(). All three task entry points incmd/lk/app.gogo through this function. On macOS and Linux,os.TempDir()already returns$TMPDIRor/tmp, and task uses the systemmktempthere anyway, so behaviour doesn't change.Test
TestTaskMktempWithoutTMPDIRunsetsTMPDIRand runs the samemktemp/>> "$tmp"pattern the template uses. It checks that the temp path is absolute and writable. Asserting the path is absolute matters: if\tmphappens to exist on the current drive,/tmp\NNNresolves and the bug is hidden.On Windows 11 / Go 1.27.3,
go test ./pkg/bootstrap/:task: Failed to run task "mk": exit status 1Not in scope
projects/p_/in the console link):p_is hardcoded in the template'sCONSOLE_URL, so this change doesn't affect it. Before this fix, though, the link'sagentNamedidn't match the agent's actual name, because the rename step failed. That may be part of what made the link look dead.should have permissions 600warning mentioned in lk app create: mixed Unix/Windows path (/tmp\...) causes post_create task to fail silently on Windows #911 is a separate issue.