Repository navigation
add in-app updates for rstudio desktop on macos and windows - #19399
Conversation
The desktop now checks a per-channel releases.json feed itself and, when
an update is available, downloads it in the background and installs it
on restart ("Install and Restart"). macOS hands the feed to Electron's
autoUpdater (Squirrel.Mac), which installs from a zip of the signed app;
Windows downloads the NSIS installer, verifies its SHA-256, and runs it
silently with the new /update switch once RStudio has quit, after which
the installer relaunches RStudio as the user. GWT keeps every dialog and
the usual quit sequence; the desktop reports download completion through
desktopHooks.
Where no feed is published for a build (Linux, dev builds, or until the
CDN prefix exists), the desktop answers "unsupported" and the session's
existing check and "Quit and Download" dialog run unchanged.
Packaging: make-package now also produces RStudio-<version>.zip, the
notarize script accepts it, package/update-feed.cmake writes the feed
entry, and the macOS/Windows Jenkins pipelines upload the zip and publish
the feed when RSTUDIO_UPDATE_FEED_BUCKET is configured.
Addresses #17173
dailies.rstudio.com already publishes every build with its link and SHA-256: /api/v1/release/index.json resolves the current release's newest published build, and the branch (daily, preview) and rstudio-hourly indexes cover the other channels. Use that instead of generating and hosting a releases.json, which removes package/update-feed.cmake, the "Publish Update Feed" Jenkins stages, and the CDN prefix and Jenkins variables they needed. Squirrel.Mac still wants its own feed shape, so on macOS the updater serves a one-entry document for the chosen build from a loopback listener. The zipped .app it installs from is now published to the builds site as the electron/macos-zip platform; until that entry exists for a build, macOS offers the DMG through the "Quit and Download" path. A branch index can briefly list artifacts of two builds while the site rebuilds, so the install artifact is only used when it is the same build as the one offered. Addresses #17173
|
Companion PR for the builds site: rstudio/latest-builds#281 adds the |
Pro desktop builds (a .pro version suffix) never update in-app: Workbench has its own distribution and will need its own update infrastructure. The updater answers "unsupported" for them, make-package skips the zip, and the macOS pipeline skips notarizing, uploading and publishing it. Administrators can keep the update notification but send users to the download page instead with allow-in-app-updates=0 in rsession.conf or the RSTUDIO_DISABLE_IN_APP_UPDATES environment variable, following the posit-assistant-installation-enabled pattern; the session reports it as allow_in_app_updates and GWT then uses the session's check only. Addresses #17173
… safer windows staging - drop the allow-in-app-updates session option: packaged Desktop passes --config-file none and allowOverlay() is true in open-source, so it could never turn the feature off; RSTUDIO_DISABLE_IN_APP_UPDATES, now read by the desktop itself, is the single switch - daily and hourly builds follow the branch the release index lists as in development instead of the branch they were built from, so a build is not stranded on its old branch after a release cut - "Restart Now" first asks the desktop whether the update can be applied; on Windows that means no other rstudio.exe is running, since the installer refuses to run beside one and quitting one window would strand the user - windows staging: reuse an already verified installer (another instance, or "Later" followed by a relaunch), download under a private name until verified, prune installers no newer than the running build at startup, and recheck the installer exists before launching it - report the artifact actually downloaded on macOS rather than whatever the latest check found - notarize-release.sh requires a clean notarytool exit and an Accepted status for both the DMG and the zip - dismiss a previous download indicator before showing another
…nstall, re-offer the restart - Electron's renderer, GPU and utility children are also rstudio.exe, so the other-instance probe excludes every pid in app.getAppMetrics() - the Windows staging directory is keyed by the install directory, so a second copy of RStudio (an unpacked zip, say) never prunes or reuses another installation's staged installer; a staged installer is also re-verified before being reported ready again - when the "close other windows" warning is dismissed, the restart dialog is shown again rather than requiring another update check
…ancel an abandoned install, reopen the project - the in-flight download guard is taken before anything is awaited, so two overlapping requests can no longer both start - canInstallUpdate() now answers why not: "missing" when the staged installer no longer verifies (GWT downloads it again) or "other-instances" - a pending install is cancelled when the client abandons its pending quit (the session refused it, or the user cancelled), so a later ordinary quit does not install; the download stays staged - the active project is remembered in relaunch-project.json before the quit and reopened once by the relaunched RStudio, matching Restart RStudio; the marker expires after 15 minutes
…he aliased project path - forgetRelaunchProject() logs instead of throwing, so a marker that cannot be removed never stops startup - the session reports the active project as ~/..., which existsSync cannot see; the desktop resolves it before remembering it (the no-project sentinel passes through)
… marker to the installed build, test the staging rules - the Windows preflight runs again inside onReadyToQuit, since another RStudio window may have been opened while the save prompts were up - relaunch-project.json now names the build and installation it is for; only that build, running from that install directory, consumes it, so an older build or another installation launched in between leaves it alone - the Windows staging rules (reuse a verified installer, download beside the final name, verify size and checksum, prune obsolete files) move to installer-staging.ts with an injected fetch and get behavioural tests against real files: checksum mismatch, truncated download, HTTP error, reuse without fetching, replacement of a corrupt file, pruning
…ch marker per installation - otherRStudioProcessCount() answers null when tasklist fails, and the preflight (and a failed IPC call) then report "unknown", which keeps RStudio running with its own message instead of letting the installer give up silently after the quit - relaunch markers live in relaunch-project/<install key>.json, so two installations never overwrite or cancel each other's; a marker is only reopened if it could also be removed, so it is consumed at most once
Squirrel.Mac waits for every process of the bundle to exit, so a second project window blocks the install just as it does on Windows. The probe moves to running-instances.ts, listing rstudio.exe with tasklist on Windows and this installation's executable with ps on macOS, and the preflight runs on both platforms.
Two launches of the updated build can both read the marker before either removes it; unlink() succeeds for one of them only, so the project is reopened exactly once. The marker directory is a parameter so the race and the per-installation rules are unit-tested against a scratch directory.
…nce probe and the marker claim - installationKey() lower-cases the directory only on Windows; a macOS volume may be case-sensitive, so two installations differing by case keep distinct keys - otherInstanceCount() takes the platform and a command runner, and is tested for own-process exclusion, foreign instances, a failed listing (null, not 0) and platforms without an installer - the marker claim is its own function, so the test can interleave two readers before either claims; the undeletable-marker case is tested with a read-only directory
RStudio E2E - all platformsAll tests passed!
View / download the full reportView report online -- opens in the browser, no download needed. Available for 14 days. Download playwright-report.zip -- extract and open
All platforms - commit |
…aunch marker atomically - every update offered this session is kept by version, and downloadUpdate() takes the version the accepted dialog showed, so a dialog that outlived a later check cannot stage the newer build the user may have declined - the relaunch marker is written to a private name and renamed into place, so a launch reading it concurrently never sees (and discards) a partial file
…load for another build The restart dialog, its preflight and installUpdate() now all carry the version they are about, so a stale dialog can no longer install whatever was downloaded last; a request to download another build while one is in progress is reported instead of dropped; the relaunch marker's cleanup can no longer throw out of the install request; and the running-instances test uses a foreign pid that cannot collide with its own.
…the quit handoff, test the updater installUpdate() now runs the preflight itself and records the install in the same turn, answering GWT like canInstallUpdate() so the quit follows only on success; downloads are refused while an install is pending; the quit handoff checks again and tells the user when it cannot install; and GWT drops the pending quit when R returns to its prompt after acknowledging one (.Last() or the workspace save failed). The updater's surroundings are an injectable host, with tests for these state transitions.
…dow during the install handoff The session now sends a quit_aborted client event when R refuses a quit it had acknowledged (.Last() or the workspace save failed), whether quit() returns or R long-jumps back to its prompt; ApplicationQuit drops the pending quit on it, replacing the console-prompt heuristic. The main window refuses to close while applyPendingUpdate() is deciding, so the process cannot end before the installer is launched. Updater tests cover the handoff flag and the release channel's chained requests.
…er prompts, one quit at a time The definition had landed in rstudio::session while callers bind to http_methods::, which the dynamic-lookup link let through; a browser() prompt inside .Last() no longer counts as an abandoned quit; and GWT ignores a quit request while one is in progress, so an abort event can only ever belong to the current attempt.
…itch's progress on an aborted quit launchInstaller() resolves once the installer has spawned or refused to, with the window held open meanwhile; a refusal drops the relaunch marker and warns the user like the other handoff failures. ApplicationQuit keeps the quit's progress indicator and dismisses it when the session reports the quit aborted, which a project switch would otherwise leave up.
…cannot start performQuit() now answers whether it started the quit, with the one-at-a-time guard moved there from QuitCommand; the restart dialog cancels the install it had just recorded when a quit (a project switch, say) is already under way, so that quit's exit neither installs nor reopens the old project.
ApplicationQuit.claimQuit() reserves the one quit in progress for a caller that must arm something first; the update restart and the renv R switch claim it before the desktop frame records the install or holds the R, and release it when that fails, so a quit already under way can neither consume what they armed nor be cancelled by them. cancelPendingInstall() drops only the named version's record, and the quit handoff installs nothing when the record was cancelled while its checks ran.
…ct out of the installer, test the quit gate setPendingRVersion() now gives the chosen R thirty seconds to describe itself (detectREnvironmentAsync kills it after a timeout) so a hung R cannot hold the quit claim forever; the Windows installer runs without RS_INITIAL_PROJECT and RS_INITIAL_WD so its relaunch consumes the relaunch marker; and the one-quit-at-a-time logic is a plain QuitGate with GWT unit tests for overlapping claims, release, reuse and reopening.
…irst detectREnvironmentAsync() answers a timeout with its error before parsing or caching the output, so an R that describes itself and then hangs is not restarted into; tested with a stand-in R that answers and sleeps.
A restart accepted while an acknowledged quit waits in .Last() would replace the desktop frame's pending quit, so the session's exit would restart it instead, leaving the quit gate closed for good.
…-auto-update # Conflicts: # src/gwt/src/org/rstudio/studio/client/renv/RenvRVersionManager.java
…g, mark at handoff - quit_session: an aborted quit (an error in .Last()) now puts back the project, working dir, project id, next session url / switch-to-project path and R version it had written down, so a later ordinary quit is an ordinary quit; covered by a server e2e test - the automation bridge reports the session ready again on quit_aborted - running-instances: the tasklist / ps call times out (30s) and answers null, so a stalled listing cannot hold the quit claim forever - updater: the relaunch marker is written at the handoff to the installer rather than when the restart is accepted, so its 15-minute lifetime no longer runs during the session's shutdown
…dows' switch - an aborted R version switch also puts back the project's last R version (and its .Rproj.user hint), which setProjectLastRVersion() had overwritten - the switch-to-project setting is shared by a desktop installation's windows: restore it only while it still holds this session's own entry
gtritchie
left a comment
There was a problem hiding this comment.
Requesting changes on the in-app update flow. The inline comments cover the details; in rough order of severity:
- On Windows, a silent update that fails or is refused (UAC cancelled, the 60s wait, install errors) leaves RStudio closed and never relaunches it.
- The new quit gate never reopens if a quit stalls before the session answers, so later quits, including closing the window, are ignored.
- An accepted install can be applied by a later, unrelated quit.
- Preview builds are offered unpublished patch candidates (confirmed against the live API).
- The Windows installer runs silently with no Authenticode check.
- The desktop check drops the session check's urgency and its server-side "no update" answer.
The rollback of an aborted project or R-version switch in 80dc196 and 0df2d68 resolves what I would have raised about notifyQuitAborted leaving the switch state behind.
The PR description still documents allow-in-app-updates=0 in rsession.conf and an allow_in_app_updates session flag. Neither exists any more; only RSTUDIO_DISABLE_IN_APP_UPDATES remains (as package/README.md says).
| ; RSTUDIO CHANGE - an in-app update ends by bringing RStudio back. Run it as | ||
| ; the user who launched the updater, never as the elevated installer. | ||
| ; | ||
| ${If} $UpdateMode = 1 |
There was a problem hiding this comment.
The relaunch only happens on the success path. Every other way the silent installer can exit leaves RStudio closed, with nothing telling the user why:
- UAC cancelled, or a user with no admin credentials on an all-users install. In silent mode, NsisMultiUser's
MultiUser.Elevate(pinneda33d494c62ad) handles error 1223 withSetErrorLevel+Quitin the outer instance, so this section never runs. rstudio.exestill running after the 60s wait, which hits theAbortat line 712.- Any install error.
The result is neither RStudio nor the update, which the preflight checks were written to prevent. Suggestions: have the outer instance relaunch RStudio whenever the inner one fails or is refused, and/or have canInstall() decline all-users installs when the user can't elevate.
There was a problem hiding this comment.
Fixed in 5c7a902, both suggestions. In update mode .onInit now elevates an all-users install itself with UAC_RunElevated before MULTIUSER_INIT (NsisMultiUser's Elevate quits the outer instance right after the inner one returns, and .onGUIEnd is not called in silent mode, so there was no later hook): a declined prompt, a failed elevated instance, or a non-zero inner exit code shows a message and relaunches the registered rstudio.exe as the user. .onInstFailed does the same for an install that fails in the instance talking to the user, and the 60s timeout now shows its message instead of auto-answering it. On the desktop side (02697a6) canInstall() declines an all-users install unless the user is in the Administrators group (whoami /groups), so a credentials prompt is never raised. I have no way to run NSIS here, so this part is unverified.
| RVersionSpec switchToRVersion, | ||
| Command onQuitAcknowledged) | ||
| { | ||
| if (!quitGate_.start()) |
There was a problem hiding this comment.
The gate closes here and reopens only in onFailedToQuit / onQuitAborted. A quit that stalls before the session answers therefore makes every later quit a no-op, including the one that closing the main window sends through desktopHooks.quitR().
Ways it can stall:
- The
setPendingQuitIPC rejects.desktop-bridge.ts:469logs the error and never calls the callback. - A
LastChanceSaveEventtoken is never released. quit_sessionnever answers.
Before this change, closing again re-ran the sequence (the closeEvent comment in main-window.ts, #18818). Now the window can't be closed short of killing the process. The new 30s process-listing timeout doesn't cover these cases. Possible fixes: a timeout on the gate, or reopening it when quit is requested again after some time has passed.
There was a problem hiding this comment.
Fixed in c49af2f. QuitGate now admits the next quit once the one in progress is 30s old (kStaleQuitMs), which restores the close-again-re-runs-the-sequence behaviour for a stalled quit; the abort race the gate exists for is accepted only for a quit that old, documented in the class comment. The bridge's setPendingQuit also calls back on an IPC error now, which was the first of the three stall routes.
| String switchToProject, | ||
| RVersionSpec switchToRVersion, | ||
| Command onQuitAcknowledged) | ||
| public boolean performQuit(TutorialApiCallContext callContext, |
There was a problem hiding this comment.
All callers ignore the new false return, so a refused quit is silently dropped:
Projects.java:1066passes aTutorialApiCallContextthat never receivesAPI_SUCCESSorAPI_ERROR, so the tutorial call never completes.Projects.java:779(create project) carries on as though the quit happened.DesktopApplicationHeader.java:562(Quit and Download) has already opened the browser by the time the quit is refused.
At minimum, the tutorial path should fire API_ERROR on refusal.
There was a problem hiding this comment.
Fixed in c49af2f. A refused performQuit shows "RStudio is already quitting or switching projects" and fires API_ERROR for a tutorial caller; the Quit and Download path now opens the browser only when performQuit returns true. The create-project path gets the same dialog, which is the only sensible outcome there (the project exists, the switch did not happen).
| // an accepted update is applied now that the session has exited; on | ||
| // macOS Squirrel closes the window and relaunches the app itself | ||
| const updater = appState().gwtCallback?.updater; | ||
| if (updater?.hasPendingInstall()) { |
There was a problem hiding this comment.
applyPendingUpdate() runs on any quit(), while the armed install is only cancelled by setPendingQuit(NONE). A quit that turns into something else therefore leaves the install armed:
- Terminate R: a quit hangs on busy R and the user chooses Terminate R.
ApplicationInterrupt.java:242setsPENDING_QUIT_RESTART_AND_RELOAD, not NONE. The session restarts and the page reloads with a fresh gate, butpendingInstallstays set, so a later ordinary quit runs the installer. - Renderer crash:
closeEvent's renderer-crash fallback callsquit()while rsession is still alive, which launches the installer beside a live session.
onSuspendAndRestart guards one restart path; ApplicationInterrupt and session-launcher's collectPendingQuitRequest / launchNextSession don't. Tying the install to the PendingQuitAndExit exit it was recorded for, or cancelling it whenever the pending quit is collected as anything else, would cover all of them.
There was a problem hiding this comment.
Fixed in 02697a6. collectPendingQuitRequest() cancels the pending install unless the exit was collected as PendingQuitAndExit, which covers Terminate R, suspend/restart and crashes in one place, and MainWindow.quit() applies the update only once the session process has exited, so the renderer-crash close cancels it rather than launching the installer beside a live session. Covered by a gwt-callback unit test.
| 'update-version': update.download.version, | ||
| 'update-url': update.download.url, | ||
| 'update-message': `RStudio ${update.download.version} is now available (you're using ${this.currentVersion})`, | ||
| 'update-urgent': '0', |
There was a problem hiding this comment.
On macOS and Windows this answer replaces the session's rstudio.org check_for_update result. That drops two things:
- Urgency. It is hard-coded to
'0', so an urgent update now gets "Ignore Update" (DesktopApplicationHeaderhides it only when urgency != 0), and once ignored it stops prompting in automatic checks. - Posit's server-side switch. An
up-to-dateanswer skips the session check entirely, so a release pulled fromcheck_for_updatebut still listed as published on the builds site keeps being offered with one-click install.
Could the desktop result be merged with the session's answer, or at least respect its urgency and its "no update" answer?
There was a problem hiding this comment.
Fixed in 02697a6 for release builds: the desktop's answer carries confirm-with-session, GWT then runs the session check too, and UpdateCheckResult.reconcile lets it have the final say: an empty session answer means no update, a session-only update is offered as before (Quit and Download), and otherwise the installable update takes the session's urgency. Daily and preview builds stay builds-site-only: I checked and rstudio.org's check_for_update answers an empty result for daily versions, so gating them on it would suppress every daily update. Covered by a GWT unit test.
| this.pendingInstall = null; | ||
| const staged = this.staged; | ||
| const mode = this.windowsInstallMode; | ||
| if (blocker || (this.host.platform === 'win32' && (!staged || !mode))) { |
There was a problem hiding this comment.
The !mode case is first caught here, after the session has shut down. preflight() doesn't check windowsInstallMode, so canInstallUpdate and installUpdate both return '' when it is null.
Scenario: a later check overwrites the mode with null (canInstall() reassigns it on every check that finds an update, and a transient reg.exe failure returns null). Restart Now then passes, the session quits, and RStudio exits without updating, with the message "The downloaded update is no longer available". Checking the mode in preflight(), or keeping the last good mode, would surface this before the quit.
There was a problem hiding this comment.
Fixed in 02697a6: canInstall() keeps the mode from the last check that could read it, so a transient reg.exe failure after a download no longer clears it. Unit test added.
| autoUpdater.on('update-downloaded', onDownloaded); | ||
| autoUpdater.on('update-not-available', onNotAvailable); | ||
| autoUpdater.on('error', onError); | ||
| autoUpdater.setFeedURL({ url: feedUrl, serverType: 'default' }); |
There was a problem hiding this comment.
If setFeedURL() or checkForUpdates() throws synchronously here (for example "Could not get code signature" on an unsigned build), the error goes to .catch(reject) without settle():
- The three
autoUpdaterlisteners stay attached. - The loopback server keeps listening.
- On the next attempt, a stale handler's
settle()closes the new attempt's server.
Wrapping this block in try { … } catch (e) { settle(() => reject(e)); } would cover it.
There was a problem hiding this comment.
Fixed in 02697a6: the two calls are wrapped and a throw goes through settle(() => reject(...)), so the listeners and the loopback server are released.
| */ | ||
| export function installerEnvironment(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv { | ||
| const clean = { ...env }; | ||
| delete clean[kRStudioInitialProject]; |
There was a problem hiding this comment.
Only these two variables are stripped. The installer, and the RStudio it relaunches, inherit everything else the running desktop has mutated in process.env:
R_HOMEand the other R variables, viasetVarsindetect-r.ts- a
PATHwith R's bin directory prepended (detect-r.ts:327) RSTUDIO_WHICH_Rfrom the R chooser- test overrides such as
RSTUDIO_UPDATE_VERSION, which makes the new build offer the update again
Snapshotting the environment at startup and spawning the installer with that copy would cover all of these.
There was a problem hiding this comment.
Fixed in 02697a6. process.env is snapshotted when the module loads (before any R is detected) and the installer is spawned with that copy, still minus the two project variables and now also minus RSTUDIO_UPDATE_VERSION, so the relaunched build does not keep offering the same update.
| } | ||
|
|
||
| private async stagedInstallerVerifies(): Promise<boolean> { | ||
| return this.staged !== null && (await this.host.verifyInstaller(this.staged.file, this.staged.entry)); |
There was a problem hiding this comment.
This re-reads and hashes the whole ~300 MB installer on every call. One Restart Now runs it at least three times (canInstallUpdate, installUpdate, applyPendingUpdate), and the last pass runs while handingOff holds the window open after the session has exited.
Caching the verified result keyed on size + mtime (or keeping the file open after verifying it) would avoid the repeated passes.
There was a problem hiding this comment.
Fixed in 02697a6: the staged installer's size and mtime are recorded when it last hashed correctly, and an unchanged file is trusted without re-reading it (the stamp is taken before hashing, so a change after the stat forces a re-hash next time). Unit test covers the three-call sequence.
| // twice): nothing is recorded for it, and the update | ||
| // stays downloaded for the next check | ||
| ApplicationQuit.QuitClaim claim = appQuit_.claimQuit(); | ||
| if (claim == null) |
There was a problem hiding this comment.
When the claim fails, the user has just answered the save prompts and then nothing visible happens. The only trace is a console log, so they can't tell the update wasn't applied. RenvRVersionManager shows quitAlreadyInProgress in the same situation; the same message (or a reworded one) would work here.
There was a problem hiding this comment.
Fixed in c49af2f: a failed claim shows the same "already quitting or switching projects" message the renv path uses.
The quit gate reopened only when the session failed or aborted the quit, so a quit that stalled before the session answered (a setPendingQuit IPC that rejected and never called back, a last-chance save that never completed, a busy session) left every later quit, including closing the window, ignored. A quit older than 30s now admits the next one, which re-runs the sequence as closing the window again always did; the bridge calls back on an IPC error instead of dropping the quit. A refused quit also tells the user (the save prompts have usually just been answered) and fails a tutorial API caller instead of leaving it waiting.
- an accepted install is applied only by the quit-and-exit it was recorded for: a session exit collected as a restart or a crash, or a quit with the session still alive, forgets it rather than leaving it armed for a later quit - preview builds, and dailies left on a released branch, read the release API once their branch is released, and a branch index whose newest build is on another channel (release candidates) offers nothing, so unpublished patch candidates are never offered - release builds are marked confirm-with-session: GWT runs the session's check_for_update too and takes its urgency and its "no update" answer - the staged Windows installer must carry a valid Authenticode signature from Posit's certificate (Get-AuthenticodeSignature), checked once per download; an all-users install is only updated in-app for an administrator, who can consent to the UAC prompt - the installer download gives up after a minute without data - a persistent Squirrel 'error' listener covers quitAndInstall() failures after the download's listener is gone, and a synchronous throw from setFeedURL/checkForUpdates settles the download - the Windows install mode is kept from the last check that could read it - the installer runs with the environment RStudio was launched with, minus RSTUDIO_UPDATE_VERSION, rather than the one detect-r rewrote - the staged installer is hashed once while its size and mtime are unchanged
The /update installer relaunched RStudio only on success; a declined UAC prompt, a failed elevated install, an install error or RStudio still running after the wait left the user with neither RStudio nor the update, silently. An all-users update now elevates from .onInit itself (NsisMultiUser would quit the outer instance as soon as the elevated one is done, whatever the outcome) and relaunches the registered RStudio with a message when the elevated instance fails or is refused; .onInstFailed does the same for an install that fails in the instance talking to the user; and the wait timeout tells the user instead of aborting silently.
|
Thanks for the thorough review. All fourteen points are addressed in c49af2f, 02697a6 and 5c7a902 (see the inline replies). Two notes: the session-check gate applies to release builds only, since rstudio.org's |
…elaunch - reconcile(): the desktop's installable update is used only when the session names the same version; a differing session answer wins - an install request still in its checks learns of a cancellation (the session replaced meanwhile) and records nothing - a superseded renv R-version claim clears the pending R instead of leaving it for the next quit - setPendingQuit reports an IPC failure to the quit sequence, which then does not quit (the exit would be taken for a crash) rather than quitting without the frame's record; Command callers run only on success as before - the relaunch marker also names the build the update was attempted from, so the installer's relaunch after a failed update reopens the project - the NSIS relaunch only reopens an RStudio that is still intact and says to run the installer otherwise - a retried quit dismisses the stalled attempt's progress indicator
…elaunch flag - the desktop frame publishes a prepared R only when the quit that names it is recorded (setPendingQuit now takes the executable), so a superseded or late R-switch claim leaves nothing for another quit; the clear IPC goes - a quit the frame could not record also leaves nothing armed: quitNotStarted sends PENDING_QUIT_NONE in every not-started path - the previous build takes the relaunch marker only when launched with --after-failed-update, which the installer passes; an ordinary launch while the installer waits leaves it for the updated build - the installer tracks whether the sections began changing the installation (the elevated instance reports it through its exit code) and offers a repair message instead of relaunching after that point, or when the relaunch itself fails
… abort test - setPendingQuit() normalizes the R the client names the same way setPendingRVersion() did (bin\R.exe -> bin\x64\Rterm.exe on Windows), so the prepared R is found and published - the aborted-switch e2e test no longer relies on R reissuing its prompt after the refused quit: it waits for the bridge to report the session usable and runs a command to completion instead
gtritchie
left a comment
There was a problem hiding this comment.
Thanks for the quick and thorough turnaround. I checked all fourteen fixes in the code. Where a fix depends on outside data I checked it against live services: the session-check reconcile (rstudio.org returns update-version in the same 2026.10.1+239 form as the builds site) and the released-branch path for preview builds (blue-mistflower resolves to 2026.10.1+239). They all look right. I followed the NSIS failure paths in the template but, like you, couldn't run them on Windows.
Requesting changes again for four new issues in the follow-up code (inline):
- PowerShell injection in the Authenticode check (security). The API-supplied filename reaches the PowerShell script with only ASCII
'escaped, so a compromised API can run code inside the very check meant to stop it. - A stalled quit's late failure can undo the newer quit it let in.
- Blocked PowerShell makes every Windows download fail. Each attempt downloads ~300 MB and then fails the signature check.
- The signature is checked once, then the file is trusted on size and mtime alone at the handoff.
The failing desktop e2e test (git_diff_gutter.test.ts:3912, "keeps the action bar of a folded change when wrapping pads at the fold") is unrelated to this PR. It is tracked in #19436 and fails the same way on other PRs.
| export function signatureScript(file: string): string { | ||
| // a single-quoted PowerShell string takes everything literally except the | ||
| // quote itself, which is doubled | ||
| const literal = `'${file.replace(/'/g, "''")}'`; |
There was a problem hiding this comment.
This escapes only the ASCII '. PowerShell also ends a single-quoted string at U+2018, U+2019, U+201A and U+201B. The path comes from entry.filename, which the builds API supplies and nothing validates (update-feed.ts:349, then path.basename in installer-staging.ts:98).
That opens the signature check to the attack it exists to stop. A compromised API publishes a filename such as RStudio’; Start-Process calc; ’.exe, the download lands under that name, and this script runs the injected command as the user before any signature is checked.
It also breaks honest updates: a profile path containing ’ (for example C:\Users\D’Arcy\AppData\Local\Temp\...) makes every check fail.
Suggested fix: keep the path out of the script text. Run a fixed script that reads -LiteralPath $env:RSTUDIO_AUTHENTICODE_FILE, and set that variable when spawning. Separately, reject API filenames that don't match a strict pattern (e.g. /^RStudio-[A-Za-z0-9.+-]+\.exe$/) before downloading.
There was a problem hiding this comment.
Confirmed: PowerShell also ends a single-quoted string at U+2018..U+201B. Fixed in be640a7. The script is now fixed text that reads -LiteralPath $env:RSTUDIO_AUTHENTICODE_FILE, and the runner sets that variable when it spawns PowerShell (CommandRunner takes an optional env). The test passes a path containing ', ‘ and ’ plus an injected Start-Process, and checks that none of it reaches the arguments.
1b9503f also refuses, before fetching anything, any filename other than the builds site's own installer name for the version being offered (installerVersion(filename) === entry.version, .exe). That's the same parse pruneStagedInstallers() uses, so a staged file is always one the pruner can clean up. All Windows names in the live API pass it.
| * and leave nothing armed in the desktop frame (an update install | ||
| * recorded for this quit, the R it named) for a later, unrelated quit. | ||
| */ | ||
| private void quitNotStarted(String message, GlobalProgressDelayer progress) |
There was a problem hiding this comment.
Once QuitGate admits a second quit after 30s, the first (stalled) QuitCommand still holds live callbacks. If it fails later, its quitNotStarted() reopens the gate, clears isQuitting_ and sends setPendingQuit(NONE), all while the second quit is in flight.
Scenario:
- Quit 1 is queued behind busy R.
- After 30s the user closes the window; quit 2 records
PENDING_QUIT_AND_EXITand sends its ownquit_session. - When the session exits, the stale attempt's RPC errors and sends
PENDING_QUIT_NONE. - If that IPC reaches the main process before
collectPendingQuitRequest(), the exit is taken for a crash and an accepted update install is cancelled.
Even when it arrives too late to do that, it still reopens the gate mid-quit. A generation counter on QuitCommand, letting only the current attempt reopen the gate or clear the frame, would close this. I haven't reproduced it; it follows from the callback lifetimes.
There was a problem hiding this comment.
Agreed, and it's a little wider: quit_session answers before it quits (SessionHttpMethods.cpp:1370), so whichever request the session reads first wins and the other fails when the process exits. If quit 1 stalled in its saves or in the desktop callback, quit 2's request goes first and quit 1 fails late, which is your case. If quit 1 stalled behind a busy session, its request is queued ahead, and the current attempt's RPC is the one that fails. A generation counter alone would still send PENDING_QUIT_NONE there.
Fixed in e5f2ba0. QuitGate.start() and Claim.start() now return an Attempt. Only the latest attempt's fail() reopens the gate, clears isQuitting_ and sends PENDING_QUIT_NONE, and none does once the session has accepted any attempt (acknowledged() on a true answer). An accepted quit ends with the page or with quit_aborted; an acceptance that arrives after the abort is ignored. A replaced attempt also stops before arming the frame or sending its own quit_session, and a claim replaces a stalled attempt too. The cases are in QuitGateTests. Not reproduced end to end.
| // installer runs silently (no UAC prompt for a per-user install), so | ||
| // it must also be what Posit signed. Checked once per download: later | ||
| // checks compare the file against this very checksum. | ||
| const signature = await installerSignature(file, execFileRunner(kSignatureCheckTimeoutMs)); |
There was a problem hiding this comment.
The signature check only happens after the full download, and a null answer (PowerShell missing, blocked by AppLocker, or in Constrained Language Mode) deletes a genuine installer and fails the download.
On such a machine can-install is still true, so every Install and Restart downloads ~300 MB and then fails with "not signed by Posit Software, PBC (unknown)", the same way each time. Probing the check once in canInstall() (for example against process.execPath, which is signed by the same certificate), and treating failure as "cannot install", would send these users to the manual download instead.
There was a problem hiding this comment.
Agreed. Fixed in 9c5d75b: canInstall() probes once per process, and a failure answers can-install: false, so these users get the manual download.
One change from your suggestion: the probe accepts any answer about process.execPath, not a valid Posit signature. Hourly builds sign only the installer (Jenkinsfile.windows signs executables only for DAILY builds), so an hourly rstudio.exe reports NotSigned, and requiring Posit's signature would turn in-app updates off for hourly. The probe only needs to show that the check runs; the installer still has to be signed by Posit.
| staged.stamp = null; | ||
| return false; | ||
| } | ||
| if (staged.stamp && staged.stamp.size === stamp.size && staged.stamp.mtimeMs === stamp.mtimeMs) { |
There was a problem hiding this comment.
With the stamp cache (which I suggested), the Authenticode check runs once at download time. Every later check, including the one at the handoff to the installer, then trusts the file on size + mtime alone.
A process running as the user can swap in a same-size executable and restore the mtime, and it is launched without re-verification. For a per-user install that adds little to what such a process can already do. For an all-users install, though, it then runs elevated on the admin's UAC consent.
Keeping the cache for the two earlier checks, but forcing a full hash (or the signature check) once in applyPendingUpdate() just before launchInstaller, would close this at the cost of one read.
There was a problem hiding this comment.
Agreed. Fixed in 9c5d75b: applyPendingUpdate() hashes the staged installer in full just before launchInstaller, whatever its stamp says. The two earlier checks keep using the stamp. On a mismatch it doesn't launch, shows the "no longer available" warning, and clears the stamp so the next check hashes again. Tests cover a clean handoff and a swapped file with the same stamp.
PowerShell ends a single-quoted string at U+2018..U+201B as well as the ASCII quote, so quoting the API-named path into the script was injectable. Addresses #17173.
…andoff Where PowerShell cannot answer, every download fetched the whole installer and then failed its signature check; such users now get the manual download. The probe accepts any answer, since hourly builds sign only the installer. The handoff no longer trusts the size+mtime stamp. Addresses #17173.
…cepted A replaced attempt's late failure reopened the gate and sent PENDING_QUIT_NONE under the quit that replaced it. The session answers whichever quit_session it reads first and exits, so either request can be the one that fails; once any attempt is accepted, only quit_aborted reopens the gate. Addresses #17173.
A replacement attempt that failed first undid the quit even though the session could still accept the older request, and releasing a claim reopened the gate past an accepted quit. Both now go through Attempt.fail(), which waits for every sent request to settle. Addresses #17173.
An install whose checks outlasted the quit claim could be replaced by a second restart into the same version; its late answer then cancelled the newer request's record by version. Requests now carry an id, cancels match it, and an older request finishing after a newer one started answers 'superseded' without recording. Addresses #17173.
Releasing an R-switch claim that replaced nothing sent PENDING_QUIT_NONE, clearing the pending exit a console q() records without the gate. Addresses #17173.
… checks Addresses #17173.
A restart whose saves stalled could be replaced by an R-switch claim before its quit reached the frame; releasing that claim then left the install recorded for a later ordinary quit. Addresses #17173.
|
A follow-up review pass turned up a few more races around overlapping quits and update installs; pushed as e5f2ba0..712d620:
New QuitGateTests and updater tests cover each case. One known gap: |
gtritchie
left a comment
There was a problem hiding this comment.
Approving. All four points from the last round are addressed, along with the extra races your own pass found. I checked each fix in the code, and the stricter installer-name check against the builds site's live release, daily and hourly Windows filenames (all three pass). CI is green on 712d620.
One small, non-blocking note is inline: the startup probe of the signature check. Fine as a follow-up.
| async canCheckSignatures(): Promise<boolean> { | ||
| // any answer will do, as it only shows the check runs: hourly builds | ||
| // sign only their installer, so rstudio.exe may well be NotSigned | ||
| return (await installerSignature(process.execPath, execFileRunner())) !== null; |
There was a problem hiding this comment.
Non-blocking: this probe runs under execFileRunner()'s default 30s timeout (kProcessListTimeoutMs), not kSignatureCheckTimeoutMs. canInstall() also keeps the promise for the life of the process, so a single failure is remembered for the rest of the session.
The first check usually happens at startup, when PowerShell's cold start and Defender scanning of rstudio.exe are slowest. If that probe times out, Install and Restart stays off until RStudio restarts.
Passing execFileRunner(kSignatureCheckTimeoutMs) here, and caching only a successful probe, would avoid that.
Intent
RStudio Desktop can only tell users that a new version exists and send them to the download page. This PR adds an in-app update path for open-source RStudio Desktop on macOS and Windows: the update is downloaded in the background and installed on restart, mirroring what Positron ships today. Linux keeps the notify-only flow pending #4186. Pro desktop builds (a
.proversion suffix) are excluded: Workbench has its own distribution and will need its own update infrastructure.Addresses #17173. Also the mechanism asked for in #19333.
Approach
The desktop (Electron main process) owns the mechanics; GWT keeps every dialog and the usual quit sequence. No new hosting is needed: the builds site's JSON API (https://dailies.rstudio.com/json-api/, OpenAPI at
/api/v1/openapi.json) already lists every build with its download link and SHA-256.src/node/desktop/src/main/updater.tsreads the index for this build's channel (from the version's pre-release tag):/api/v1/release/index.jsonfor releases, whosereleased[0].published[0]is the current release's newest published build; the branch index (/rstudio/<branch>/index.json) for dailies and previews;/rstudio-hourly/<branch>/for hourlies. It compares versions numerically including the build number (semver would treat two dailies as equal) and answers GWT with the same keys as the session'scheck_for_updatesRPC pluscan-install. Anything other than "available" / "up-to-date" (Linux, dev builds, a branch not on the site, the site unreachable) makes GWT fall back to the session check and today's "Quit and Download" dialog. When the API lists the DMG but not yet the zip, macOS also gets that dialog, now linking straight to the DMG.autoUpdater(Squirrel.Mac) a one-entry feed in its own format, served from a loopback listener since the dailies API is a different shape; Squirrel verifies the zip and the new bundle's code signature. The zip is the newRStudio-<version>.zipthatmake-packageproduces next to the DMG, whichnotarize-release.shnow accepts and the macOS pipeline publishes to the builds site as theelectron/macos-zipplatform. Windows downloads the NSIS installer named by the API and verifies its SHA-256 and its Authenticode signature (Posit Software, PBC). Completion is reported to GWT throughdesktopHooks.onUpdateDownloaded/onUpdateDownloadFailed.autoUpdater.quitAndInstall()on macOS, or spawning the installer with/S /<allusers|currentuser> /updateon Windows. NsisMultiUser refuses a silent run without the mode, so it is read from the registryInstallLocation; an unpacked-zip install getscan-install: falseand the manual flow. The new/updateswitch in the NSIS template waits up to 60s forrstudio.exeto exit instead of aborting, and relaunches RStudio as the user (not the elevated installer) when done.Two things learned from the live API shaped the code: a released branch's own index lists unpublished patch candidates (blue-mistflower shows 2026.10.2+241 today), which is why releases go through
/api/v1/release/; and a branch index can briefly list artifacts of two builds while the site rebuilds, so the install artifact is only used when it is the same build as the one offered.Administrator control. The
RSTUDIO_DISABLE_IN_APP_UPDATESenvironment variable keeps the update notification but sends users to the download page instead of offering "Install and Restart" (packaged Desktop builds do not read anrsession.conf, so there is no option for it). The existingRSTUDIO_DISABLE_CHECK_FOR_UPDATESstill turns update checks off entirely. Documented in the environment variables reference.For testing a build against another channel or copy of the API, the desktop honours
RSTUDIO_UPDATE_API_URL,RSTUDIO_UPDATE_CHANNEL(also enables updates for-devbuilds),RSTUDIO_UPDATE_BRANCH, and the existingRSTUDIO_UPDATE_VERSION.Rejected alternatives, for the record: a self-hosted
releases.jsonon cdn.posit.co (an earlier revision of this PR; it duplicated what the builds site publishes and needed new infrastructure);electron-updater, which is designed around electron-builder's manifests and installer conventions (we package with CPack, not Forge makers, so the "Forge vs electron-builder" question in the issue is moot); Squirrel.Windows, which would replace the NSIS installer reworked in #18167; Sparkle/WinSparkle, which need native addons.Automated Tests
.prosuffix) and comparison, channel, branch slug and index URL selection, release-index and build-index parsing and validation, the Squirrel feed document (update-feed.test.ts), and registry parsing / install-mode detection (windows-install-mode.test.ts)./updatepath, the Jenkins changes, and a real Squirrel.Mac install, which all need a signed CI build. See QA notes.QA Notes
Windows is complete as of this PR: an open-source released or daily build checks the API and, when a newer build is listed, offers "Install and Restart". macOS offers "Install and Restart" once the
macos-zipplatform is published for a newer build; until then it offers "Quit and Download" with a direct DMG link. On Linux, for Pro desktop, for developer builds, and wherever an administrator setsRSTUDIO_DISABLE_IN_APP_UPDATES, nothing changes.To exercise the flow on a signed build without waiting for a newer build, launch it with
RSTUDIO_UPDATE_VERSION=<an older version>(andRSTUDIO_UPDATE_CHANNEL=daily RSTUDIO_UPDATE_BRANCH=parrot-balsamto point a release build at the dailies):sha256viaRSTUDIO_UPDATE_API_URL) fails with an error dialog and no changes on disk.App Transport Security does not block the loopback feed: Electron's base
Info.plistsetsNSAllowsArbitraryLoads, the shipping app inherits it (checked on 2026.11.0-daily+174 in/Applications), and a probe under the same Electron 44 binary showed Squirrel fetch/releases.jsonfrom127.0.0.1, reportupdate-available, and download the zip from the same listener, failing only at unpack because the probe served garbage.Companion PR: rstudio/latest-builds#281 adds the
electron/macos-zipplatform pages for Parrot Balsam (the builds site names platforms in a per-branch_index.md), and should merge first.Documentation
package/README.mdgains an "In-app update feed" section covering which API endpoints are read, the macOS zip, the administrator option, and the test environment variables. The environment variables reference documentsRSTUDIO_DISABLE_IN_APP_UPDATES. The user-facing change is inNEWS.md; the User Guide's update section can be revised once the flow is confirmed on a release build.Checklist
NEWS.md