Louis/Thèse/Résolution des problèmes/vscode-R qui s'attache mal.md
Louis Lacoste cbe404670f
vault backup: 2026-06-12 11:43:53
Affected files:
.obsidian/workspace.json
Thèse/Axes/Phylogénie/Modèle mixte avec arbre phylogénétique.md
Thèse/Packages/R/colSBM.md
Thèse/Résolution des problèmes/vscode-R qui s'attache mal.md
2026-06-12 11:43:54 +02:00

35 lines
1.4 KiB
Markdown

La solution vient de Github de vscode-R [cette *issue*](https://github.com/REditorSupport/vscode-R/issues/1696#issuecomment-4553641300)
Had the same issue after updating R from 4.5.2 to 4.6.0. `.vsc.attach()` could not be found anymore.
The root cause is that R 4.6.0 no longer calls `.First.sys()` during startup. The extension's [init.R](cci:7://file:///C:/Users/meissnerto/.windsurf/extensions/reditorsupport.r-2.8.8-universal/R/session/init.R:0:0-0:0) relies on overwriting `.First.sys` to initialize the session watcher, so the attach function never gets defined.
Fix that worked for me (in [init.R](cci:7://file:///C:/Users/meissnerto/.windsurf/extensions/reditorsupport.r-2.8.8-universal/R/session/init.R:0:0-0:0) of the extension, for me located at `~/.windsurf/extensions/reditorsupport.r-2.8.8-universal/R/session/init.R`):
1. Change the assign call from `.First.sys` to `.First`:
```r
- assign(".First.sys", init_last, envir = globalenv())
+ assign(".First", init_last, envir = globalenv())
```
2. Remove the old.First.sys lines:
```r
- old.First.sys <- .First.sys
```
and inside `init_last`:
```r
- old.First.sys()
```
3. Update the cleanup at the end of init_last:
```r
- rm(".First.sys", envir = globalenv())
+ rm(".First", envir = globalenv())
```
After restarting the R terminal everything attaches correctly again. This should probably be patched in the extension since R 4.6.0 deprecated `.First.sys`entirely.