Skip to content

R 4.6.0: Session watcher not working #1696

Closed

Description

@benz0li

Describe the bug

'R: Creating R Terminal' results in 'R: (not attached)'.

To Reproduce

On a host with docker installed:

docker run --rm -p 8888:8888 -ti glcr.b-data.ch/jupyterlab/r/base:4.6.0

Follow the instructions in the terminal, i.e. open URL http://127.0.0.1:8888/lab?token=${TOKEN} in a browser.

Inside the container

  1. JupyterLab: Click on 'code-server'
  2. code-server: Open View > Command Palette... > R: Create R Terminal

Can you fix this issue by yourself? (We appreciate the help)

No

(If applicable) Please attach setting.json

"r.plot.useHttpgd": true,
"r.rterm.linux": "/usr/local/bin/R",
"r.rterm.option": [
  "--no-save",
  "--no-restore"
],
"r.workspaceViewer.showObjectSize": true,

Expected behavior

Session watcher also works with R 4.6.0 and later.

Screenshots

-

Environment (please complete the following information):

  • OS: Linux (Debian 13)
  • code-server Version: 4.117.0
    • aka Code Version 1.117.0
  • R Version: 4.6.0
  • vscode-R version: 2.8.8

Additional context

R version 4.6.0 (2026-04-24) -- "Because it was There"
Copyright (C) 2026 The R Foundation for Statistical Computing
Platform: aarch64-unknown-linux-gnu

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> .vsc.attach()
Error in .vsc.attach() : could not find function ".vsc.attach"

Activity

  1. benz0li commented on Apr 28, 2026

    @benz0li
    ContributorAuthor
  2. MalditoBarbudo commented on Apr 29, 2026

    @MalditoBarbudo

    @benz0li

    Having the same problem.
    I found a workaround looking at ~/.vscode/extensions/reditorsupport.r-2.8.8/R/session/init.R code. It seems like the code is correctly sourced and functions are attached, but the new .First.sys() is never called. Running it in the R console will attach the R session.

  3. benz0li commented on Apr 29, 2026

    @benz0li
    ContributorAuthor

    It seems like the code is correctly sourced and functions are attached, but the new .First.sys() is never called.

    A similar problem was reported for arf:

  4. Skolmeister commented on Apr 29, 2026

    @Skolmeister

    Good call @MalditoBarbudo, I edited my .Rprofile to call the function explicitely and now it works without manual interference:

    if (interactive() && Sys.getenv("RSTUDIO") == "") {
      init_path <- file.path(Sys.getenv(if (.Platform$OS.type == "windows") "USERPROFILE" else "HOME"), ".vscode-R", "init.R")
      source(init_path)
      # Workaround .vsc.attach()
      .First.sys()
    }

    For me this is good enough as a workaround for the moment.

  5. eitsupi commented on Apr 29, 2026

    @eitsupi
    Member

    Good point @benz0li cc @bsirak
    It seems that it now works as documented (See ?Startup).

    Currently, vscode-R behaves in a way that depends on the implementation details and does not adhere to the correct specifications.
    Should use .First() instead of .First.sys().

  6. TinasheMTapera commented on Apr 30, 2026

    @TinasheMTapera

    The weirdest thing just happened: I was perusing google after experiencing this issue and noticed this VSCode Extension hiding in the interwebs: https://github.com/WahiduzzamanKhan/rig-manager-vscode, and somehow, my problem went away. I mainly just wanted to install this extension first just for kicks:

    1. I had my project R profile and home dir R profile like this:
    # project
    if (interactive() && Sys.getenv("RSTUDIO") == "") {
      init_path <- file.path(Sys.getenv(if (.Platform$OS.type == "windows") "USERPROFILE" else "HOME"), ".vscode-R", "init.R")
      source(init_path)
    }
    
    # home dir
    if (interactive() && Sys.getenv("RSTUDIO") == "") {
      init_path <- file.path(Sys.getenv(if (.Platform$OS.type == "windows") "USERPROFILE" else "HOME"), ".vscode-R", "init.R")
      source(init_path)
      # Workaround .vsc.attach()
      .First()
    }
    
    1. I removed the regular brew version of R: brew uninstall R
    2. I switched over to rig: brew tap r-lib/rig && brew install --cask rig
    3. I added and switched to 4.5: rig add 4.5 && rig list && rig switch 4.5-arm64
    4. I installed the extension from .vsix file via Tag v0.4.0
    5. Vscode automagically configured itself and a new terminal opened all by itself
    Image

    Someone smarter than me might be able to use this info!

    Edit: still not perfect as the session hasn't fully "attached," but it's a little better:

    Image
  7. randy3k commented on May 2, 2026

    @randy3k
    Member

    I am working on the 3.0.0 release,
    3.0.0-rc1 can be find at https://github.com/REditorSupport/vscode-R/releases/tag/latest

    it should fix this issue.

  8. MartinMorlot commented on May 18, 2026

    @MartinMorlot

    I attempted building the extension, did not resolve the issue, maybe I did it wrong or using the wrong branch (master).

    However, implementing @Skolmeister 's solution worked.

  9. mihaiconstantin commented on May 18, 2026

    @mihaiconstantin

    The 3.0.0-rc1 version does seem to fix the issue, however I encountered a bug when running View(...) in a debugging context.

    After more testing, @Skolmeister's suggestion seems to work for extension version 2.8.8 with R version 4.6.0.

  10. T0bC commented on May 27, 2026

    @T0bC

    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 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 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:
    - assign(".First.sys", init_last, envir = globalenv())
    + assign(".First", init_last, envir = globalenv())
    1. Remove the old.First.sys lines:
    - old.First.sys <- .First.sys

    and inside init_last:

    - old.First.sys()
    1. Update the cleanup at the end of init_last:
    - 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.sysentirely.

  11. nsimsek-aba commented on Jun 2, 2026

    @nsimsek-aba

    The .First.sys() fix is working for me too but I was unable to implement it in .Rprofile. Waiting on a more permanent solution. Thanks all!

  12. T0bC commented on Jun 3, 2026

    @T0bC

    The .First.sys() fix is working for me too but I was unable to implement it in .Rprofile. Waiting on a more permanent solution. Thanks all!

    What do you mean by "unable to implement it in .Rprofile". Whats happening and what would you expect?

  13. nsimsek-aba commented on Jun 3, 2026

    @nsimsek-aba

    The .First.sys() fix is working for me too but I was unable to implement it in .Rprofile. Waiting on a more permanent solution. Thanks all!

    What do you mean by "unable to implement it in .Rprofile". Whats happening and what would you expect?

    I tried to put the ".First.sys()" into .Rprofile so that it would run when an active R terminal was opened in VS code without me manually typing and setting it, but it didn't register. I am still writing it into the terminal for it to attach.

  14. 16 remaining items

  15. added this to the 3.0.0 milestone on Sep 19, 2026
  16. eitsupi commented on Sep 20, 2026

    @eitsupi
    Member

    This has already been resolved in main, so I'll close it (I'll pin it instead).
    The 3.0.0 release is being tracked in #1727.

  17. pinned this issue on Sep 20, 2026
  18. eitsupi commented on Sep 27, 2026

    @eitsupi
    Member

    Version 3.0.0 has been released.

  19. unpinned this issue on Sep 27, 2026
  20. leanhdung1994 commented on Sep 28, 2026

    @leanhdung1994
  21. eitsupi commented on Sep 28, 2026

    @eitsupi
  22. leanhdung1994 commented on Sep 28, 2026

    @leanhdung1994
  23. eitsupi commented on Sep 28, 2026

    @eitsupi
  24. leanhdung1994 commented on Sep 28, 2026

    @leanhdung1994
  25. eitsupi commented on Sep 28, 2026

    @eitsupi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions