Repository navigation
Keep a remembered R following your default R after interpreter discovery - #16579
Conversation
|
E2E Tests 🚀 Why these tags?
More on automatic tags from changed files. |
There was a problem hiding this comment.
Everything looks good and the repro steps worked for me! 🚀
I wanted to check that I understand what current is doing since its new to me.
When you start an R session, the affiliated runtime record saves whether that R was the system default at that moment (current). positron-r then uses that flag to decide what to start next time:
- current: true -> you started the default R, so start whatever the default R is now. If I started 4.5 while it was my default and then run
rig default 4.6, the next window starts 4.6. - current: false -> you started an R that wasn't the default, so assume you chose it on purpose and start that exact R again, even if the default changes.
So the bug was discovery overwriting a record that should have had current: true with [false](current:). This caused the default R to not start when it should have.
Am I understanding this correctly?
|
@dhruvisompura, yep, that is correct! The idea here is that for R users, they are most often going to want whatever is "current" to start, even if they ran a different version of R before in any given workspace. This is a different behavior than Python takes, since the ecosystem is so different in terms of whether you just work with latest vs. pinning versions. |
Fixes #15992
This PR fixes one of two causes that make new windows start an older R version instead of the default R. The work in #16505, which merged today, fixes the other cause. Thank you so much, @dhruvisompura! 🎉
Background
Positron remembers the R version that you used in each workspace. Windows with no folder open share one stored R for the profile. For R, the stored record includes a
currentflag. When this flag istrue, positron-r starts the default R at launch instead of the stored binary. Thus the stored R changes when you change the default R, for example withrig default.What #16505 fixed
The interpreter discovery cache sometimes dropped interpreters, frequently both R entries. The cache reloaded its own saves as if a different window wrote them. Because of this, a new R 4.6 installation did not show in the session picker. Users then started the older R, and Positron stored it. #16505 stops the cache from reloading its own saves. It also fixes expired cache entries that did not recover.
What this PR fixes
When an interpreter registers during discovery,
onDidRegisterRuntimerefreshes the stored record with the new metadata. #14813 added this step to remove stored~/paths but it turns out the step also replacedextraRuntimeData, which belongs to the language extension.The R runtime ID uses only the binary path and the version, so the older R keeps the same ID after the default R changes. Discovery then reports the older R with
current: false, and the refresh writes that value into the stored record. After that, all new windows start the older R.This PR keeps the stored
extraRuntimeDatawhen it refreshes the record. The other fields refresh as before, so the~/path fix continues to work. When a session starts, Positron continues to save the full metadata of that session.The refresh occurs only when no R console starts at launch, for example when the R startup behavior is
manual. A launch that starts R does not change the flag. I believe this is why the problem was so difficult to reproduce!This PR does not repair a record that already has
current: false. Positron cannot tell this record from a user choice of a non-default R. To reset the record, folks will need to start the R version that they want one time.Release Notes
New Features
Bug Fixes
Validation Steps
@:interpreter @:sessions
A new unit test in
runtimeStartup.vitest.tscovers the fix. To test manually on macOS, you need rig and two R versions:rig default 4.4-arm64(or a different older R that you have).1 + 1in the console, then quit Positron.rig default 4.6.settings.json, set"interpreters.startupBehavior": "manual"in the[r]and[python]blocks. (Probably ask your favorite AI agent to do this, so you don't have to open Positron.)You can see the stored record after step 7. Quit Positron, then run this command. With the fix, the output shows
current= True: