Skip to content

fix(provisionersdk/scripts): remove existing agent binary before download#26138

Draft
ericpaulsen wants to merge 1 commit into
mainfrom
ericpaulsen/fix-bootstrap-etxtbsy
Draft

fix(provisionersdk/scripts): remove existing agent binary before download#26138
ericpaulsen wants to merge 1 commit into
mainfrom
ericpaulsen/fix-bootstrap-etxtbsy

Conversation

@ericpaulsen
Copy link
Copy Markdown
Member

@ericpaulsen ericpaulsen commented Jun 8, 2026

On Linux, bootstrap_linux.sh writes the downloaded agent directly to ${BINARY_DIR}/coder. When BINARY_DIR persists across workspace restarts (envbox sets it to $HOME/.coder) and a previous agent process is still holding the executable open, curl/wget cannot open the file for writing and fail with curl: (23) Failure writing output to destination (Linux ETXTBSY, "text file busy"). The bootstrap loop then retries forever and the workspace never recovers without manual rm -f $HOME/.coder/coder.

Unlink the existing binary before entering the download loop. unlink(2) is permitted while the file is being executed, the still-running process keeps its mapping to the old inode, and the next download creates a fresh inode that the new agent can exec. bootstrap_darwin.sh always creates a fresh mktemp -d directory, so it is unaffected.

Fixes #25975

Authored by Coder Agents on behalf of @ericpaulsen.

…load

When BINARY_DIR persists across workspace restarts (e.g. envbox sets
BINARY_DIR=$HOME/.coder) and a previous agent process is still holding
the executable open, curl/wget cannot overwrite it and fail with error
23 (Linux ETXTBSY, text file busy). The bootstrap loop then retries
forever and the workspace never becomes available.

Unlink the existing binary before entering the download loop. unlink(2)
is permitted while the file is executing, the still-running process
keeps its mapping to the old inode, and the next download creates a
fresh inode that the new agent can exec.

Fixes #25975
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.

bug: agent bootstrap script can't overwrite in-use coder binary (curl error 23 / ETXTBSY)

1 participant