Repository navigation
Description
System details
RStudio Edition : Desktop
RStudio Version : 2026.05.0
OS Version : Windows 11, but applies to all platforms
R Version : N/A
Steps to reproduce the problem
-
Launch RStudio Desktop from the command line with any flag.
Windows (PowerShell):
& 'C:\Program Files\RStudio\rstudio.exe' --remote-debugging-port=9254
macOS:
/Applications/RStudio.app/Contents/MacOS/RStudio --remote-debugging-port=9254Linux:
/usr/bin/rstudio --remote-debugging-port=9254 -
Confirm the flag took effect. For
--remote-debugging-port=9254, open a browser and visithttp://localhost:9254/json/version.- The Chrome DevTools Protocol endpoint responds.
-
Trigger an RStudio restart by invoking a command that restarts the IDE -- for example, install Posit Assistant, then invoke "Uninstall Posit Assistant" from the command palette and confirm.
-
After RStudio comes back up, check the same endpoint at
http://localhost:9254/json/version.- The endpoint no longer responds. The flag was not carried over to the restarted process.
Describe the problem in detail
When RStudio Desktop restarts itself, the new process is spawned with a freshly built argv, not by inheriting the original command-line flags. The relevant code is in src/node/desktop/src/main/application-launch.ts, where launchRStudio() constructs:
const argv = app.isPackaged ? [] : [process.argv[1]];
This drops all flags from the original launch. Any flag passed at startup -- --remote-debugging-port, --enable-logging, --user-data-dir, etc. -- is lost across a restart.
This affects test infrastructure. The Playwright test suite at e2e/rstudio launches RStudio with --remote-debugging-port=<N> so Playwright can attach over CDP. Tests that exercise an IDE restart (e.g. the Uninstall Posit Assistant flow) lose their CDP endpoint mid-test. The fixture works around this by snapshotting RStudio process IDs, killing the non-CDP self-respawn, and launching a new CDP-enabled instance.
Other flags exist that a developer might pass at startup -- e.g. --enable-logging, --user-data-dir -- and these are similarly lost on restart.
There is no observable effect on users who launch RStudio by clicking the icon, because they don't pass flags to begin with.
Describe the behavior you expected
Flags from the original launch would carry over to the restarted process, so that anything configured at first launch (debugging endpoint, log destination, user data dir) stays in effect across restarts.
Implementation note: Possibly forward CLI flags (anything starting with -) but continue to resolve positional arguments (working directory, project file) from the restart options as today.
Activity
gtritchie commentedon Oct 27, 2026
Evaluation against
mainat 6775de7.Still true
launchRStudio()builds a fresh argv and forwards only--automation-agent.launchRStudio()serves both restarts and new concurrent instances:doRestart()quits, then firesOpenProjectNewWindowEvent→Projects.onOpenProjectNewWindow→desktop_open_project_in_new_window→launchRStudio()..Rprojwhile RStudio is running.Out of date
PreferencesDialogBase.java:285), toggling the screen reader (UserPrefs.java:402), or toggling GPU driver workarounds (DesktopApplicationHeader.java:410).relaunchAfterRestartandsnapshotRStudioProcesses. Both are now unused, and no Playwright test currently exercises an IDE restart.Proposed fix
Forward the switches from
process.argv, skipping the executable, the dev-mode., and positional arguments. Project and working directory keep coming fromoptionsand the environment, as today.--: Chromium treats everything after it as plain arguments.planOzoneRelaunchalready handles this and is the pattern to follow.--run-diagnosticswould rerun diagnostics in every new window.--session-exit,--startup-delayand--session-delayare debugging aids.--version,--version-jsonand--helpexit before any relaunch, so they need no handling.--automation-agentpush: generic forwarding covers it. The electron-flags config can also add that switch, but the relaunched instance reads that config itself. The existing test atapplication-launch.test.ts:85enables automation withapp.commandLine.appendSwitch, so it needs rewriting to stubprocess.argv.--user-data-dirwould also reach new-window launches. Today, Open Project in New Session during a test starts an instance on the default Electron user data.--no-sandboxon relaunch.Caveat:
--remote-debugging-portForwarding this flag may not keep the CDP endpoint up:
ApplicationQuit.java:717), while the old Electron process is still alive. The child can lose the race for the port.app.relaunch()+app.exit()would avoid the race, since Electron starts the new instance only after the current one exits. It isn't a drop-in, though:electron-flags.ts:194).The plain forwarding change looks like the right first step. Whether the CDP port survives a restart needs testing, on Windows in particular.
Unrelated, not investigated
With no project open,
doRestart()passesProjects.NONE("none") as a project file path.launchRStudio()then setsRS_INITIAL_WDtopath.dirname("none"), which is..leave RS_LOGGER_TYPE=stderr out of a relaunched instance's environment
read the project directory without readdirSync
carry command-line switches over when desktop restarts or opens a new…