Skip to content

fix(upgrade): unpack the new binary next to the output executable - #37120

Open
Aschenbath wants to merge 1 commit into
denoland:mainfrom
Aschenbath:fix/upgrade-noexec-tmp
Open

Aschenbath wants to merge 1 commit into
denoland:mainfrom
Aschenbath:fix/upgrade-noexec-tmp

Conversation

@Aschenbath

Copy link
Copy Markdown

Closes #37116

deno upgrade unpacks the new binary into a directory from tempfile::TempDir::new() and runs it there (check_exe) before replacing the current executable. When the system temp directory is mounted noexec, running it fails with Permission denied (os error 13). That is a common hardening setup for /tmp.

This creates that directory next to the output executable instead, as .deno-upgrade-XXXXXX in the directory of the current deno or of --output. That directory has to be writable for the upgrade anyway. It also keeps the new binary on the same file system as its destination, so replace_exe can rename it into place. If the directory can't be created there (it doesn't exist, or isn't writable, e.g. a --dry-run of a deno in /usr/bin), it falls back to the system temp directory as before. TempDir still removes it afterwards.

Only the regular upgrade path changes. --pr and --branch still download into the system temp directory.

Testing

  • Added unit tests for the new helper: the directory is created in the output executable's directory and removed on drop, and it falls back to the system temp directory when the output directory is missing.
  • cargo test -p deno --lib -- tools::upgrade::test passes (31 tests). cargo clippy -p deno --lib --tests -- -D warnings and cargo fmt --check are clean.
  • I built and tested on Windows. I didn't reproduce the noexec failure end to end on Linux.

AI disclosure

This PR was written primarily by Claude Code (Claude Opus 5.5), including the change, the tests and this description. It has not yet been reviewed by a human.

🤖 Generated with Claude Code

Closes denoland#37116

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
NetOpWibby pushed a commit to theende/ende that referenced this pull request Nov 7, 2026
`ende upgrade` unpacked the new binary into a directory in the system
temp directory and ran it there (check_exe) before replacing the
current executable. With /tmp mounted noexec, a common hardening setup,
that failed with "Permission denied". Create the directory next to the
output executable instead, as .ende-upgrade-XXXXXX: that directory has
to be writable for the upgrade anyway, and it keeps the new binary on
the same file system as its destination. If it can't be created there
(say, a --dry-run of an ende in /usr/bin), fall back to the system temp
directory as before.

Only the regular upgrade path changes; --pr and --branch still use the
system temp directory.

(cherry picked from commit c64153985d2bba26e3ca829f5a6b0f8b6b779c4f)

Upstream: denoland/deno#37120
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

This branch has not been deployed

No deployments
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.

deno upgrade always fails with /tmp mounted with noexec. Hint: don't execute files in /tmp!

2 participants