Skip to content

Fix install script to change directory before cleanup - #1728

Open
Sven Giermann (Giermann) wants to merge 1 commit into
devcontainers:mainfrom
Giermann:patch-1
Open

Fix install script to change directory before cleanup#1728
Sven Giermann (Giermann) wants to merge 1 commit into
devcontainers:mainfrom
Giermann:patch-1

Conversation

@Giermann

Copy link
Copy Markdown

Two related fixes in the Go feature's "install tools" block.

  1. After installing the Go tools, the script never leaves ${GOPATH}
    (a temp dir, default /tmp/gotools) before removing it with
    rm -rf "${GOPATH}". The shell's cwd is left pointing at a deleted
    directory for the rest of the script. The two find calls that
    follow then fail while resolving their own initial working
    directory:

    find: Failed to save initial working directory: No such file or directory
    

    This is silent on filesystems/kernels where a process may keep
    using a cwd after it's been unlinked, but fails hard on at least
    some overlay2 configurations (reproduced on a Synology DSM host,
    kernel 4.4). Explicitly cd-ing to a directory that's guaranteed to
    still exist before the rm -rf makes this deterministic regardless
    of filesystem/kernel.

  2. Because of (1), the piped xargs -n 1 -0 chmod g+s received empty
    input and (GNU xargs' documented default without -r) still ran
    chmod g+s once with no arguments:

    chmod: missing operand after 'g+s'
    

    Independently of fix (1), -r/--no-run-if-empty belongs on these
    invocations regardless: chmod should never be invoked at all when
    find legitimately produces no output.

@Giermann
Sven Giermann (Giermann) requested a review from a team as a code owner September 7, 2026 12:04
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.

1 participant