Skip to content

Session watcher not attaching R and not showing plots #552

Description

@radlinsky

Hi,

Thank you so much for your work, your vscode-R package is life changing :)

I'm having issues with seeing plots (and help messages) in session watcher.

  • VSCode Version: 1.52.1
  • VSCode-R Version: v1.6.4
  • OS Version: Windows 10

Contents of ~/.Rprofile

# [cmr46993@login4 ~]$ cat ~/.Rprofile
Sys.setenv(TERM_PROGRAM = "vscode")
source(file.path(Sys.getenv(
  if (.Platform$OS.type == "windows") "USERPROFILE" else "HOME"),
  ".vscode-R", "init.R")
)
print("this is my rprofile")

Steps to Reproduce:

  1. From VSCode in Windows 10, connect to linux host with Remote-SSH
  2. Open home directory ~/
  3. Open new terminal with VS Code
  4. Activate conda environment where R and radian are installed
  5. Run radian from Terminal pane (I do see my print statement 'this is my rprofile')
  6. If I run plot(1:10, 1:10) I don't see a plot.
  7. Click R: (not attached), I see .vsc.attach() executed in radian, but no output.
  8. getOption('vscodeR') returns NULL
  9. I manually copy paste my .Rprofile and nothing changes.

I can see plots if I run R: Create R terminal but I would like to use my own managed session.. any thoughts?

Here are my vscode settings:

{
    "r.alwaysUseActiveTerminal": true,
    "r.bracketedPaste": true,
    "r.sessionWatcher": true,
    "r.rterm.linux": "/home/cmr46993/.conda/envs/mygtx/bin/radian", //Use this only for Linux
    "r.rpath.linux": "/home/cmr46993/.conda/envs/mygtx/bin/R",
    // "r.rterm.windows": "/home/cmr46993/.conda/envs/mygtx/bin/radian", //Use this only for Linux
    // "r.rpath.linux": "/home/cmr46993/.conda/envs/mygtx/bin/R",
    "r.lsp.debug": true,
    "r.lsp.diagnostics": true,
    "r.rterm.option": [
    "--no-save",
    "--no-restore",
    "--r-binary=/home/cmr46993/.conda/envs/mygtx/bin/R"
    ]
}

I see that the request.log is capturing something:

[cmr46993@login4 ~]$ cat ~/.vscode-R/request.log
{"time":"2021-02-09 18:26:08","pid":26320,"wd":"/home/cmr46993","command":"attach","tempdir":"/tmp/RtmpHWXKHB","plot":"Two"}

Do you want to fix by self? (I hope your help!)

No thanks, I am not very experienced :)

Activity

  1. renkun-ken commented on Feb 10, 2021

    @renkun-ken
    Member

    What's your workspace folder in vscode remote-ssh session?

    What's the value of ls.str(.vsc) in your R session?

  2. radlinsky commented on Feb 10, 2021

    @radlinsky
    Author

    After Remote-SSH-ing into the host, I clicked to open a folder, and selected my home directory, so I believe my workspace in this case is my home directory.

    r$> ls.str(.vsc)                                                                                                   
    attach : function ()  
    capture_str : function (object)  
    check_null_dev : function ()  
    dataview_data_type : function (x)  
    dataview_table : function (data)  
    dir_extension :  chr "/home/cmr46993/.vscode-R"
    dir_plot_history :  chr "/tmp/RtmpJP79ua/vscode-R/images"
    dir_session :  chr "/tmp/RtmpJP79ua/vscode-R"
    get_timestamp : function ()  
    globalenv_file :  chr "/tmp/RtmpJP79ua/vscode-R/globalenv.json"
    globalenv_lock_file :  chr "/tmp/RtmpJP79ua/vscode-R/globalenv.lock"
    homedir :  chr "/home/cmr46993"
    inspect_env : function (env)  
    new_plot : function ()  
    null_dev_id :  Named int 2
    null_dev_size :  num [1:2] 10.1 10.1
    path_to_uri : function (path)  
    pid :  int 175564
    plot_file :  chr "/tmp/RtmpJP79ua/vscode-R/plot.png"
    plot_history_file :  NULL
    plot_lock_file :  chr "/tmp/RtmpJP79ua/vscode-R/plot.lock"
    plot_updated :  logi FALSE
    print.help_files_with_topic : function (h, ...)  
    print.hsearch : function (x, ...)  
    rebind : function (sym, value, ns)  
    request : function (command, ...)  
    request_browser : function (url, title, ..., viewer)  
    request_file :  chr "/home/cmr46993/.vscode-R/request.log"
    request_lock_file :  chr "/home/cmr46993/.vscode-R/request.lock"
    rstudioapi_enabled : function ()  
    show_browser : function (url, title = url, ..., viewer = getOption("vsc.browser", "Active"))  
    show_dataview : function (x, title, viewer = getOption("vsc.view", "Two"))  
    show_globalenv :  logi TRUE
    show_page_viewer : function (url, title = NULL, ..., viewer = getOption("vsc.page_viewer", "Active"))  
    show_plot :  logi TRUE
    show_view :  logi TRUE
    show_viewer : function (url, title = NULL, ..., viewer = getOption("vsc.viewer", "Two"))  
    show_webview : function (url, title, ..., viewer)  
    tempdir :  chr "/tmp/RtmpJP79ua"
    unbox : function (x)  
    update_globalenv : function (...)  
    update_plot : function (...)  
    wd :  chr "/home/cmr46993"
    

    As an alternative, I tried also right now: after Remote-SSH-ing into the host, I clicked to open a single R script, rather than a folder, but I still don't get R attached, and ls.str(.vsc) looks the same.

  3. radlinsky commented on Feb 11, 2021

    @radlinsky
    Author

    Hi @renkun-ken I think I've figured out the issue!!

    As I said above, when I use R: Create R Terminal I am able to view plots. I noticed that the plots are saved to:
    /tmp/<random_id>/vscode-R/plot.png

    However, I mistakenly left out a key step in how I was trying to use session viewer, I'll rewrite it out bolding the missing step I forgot to mention I was doing:

    1. From VSCode in Windows 10, connect to linux host login node with Remote-SSH
    2. Open home directory ~/
    3. Open new terminal with VS Code
    4. Use srun to get an interactive compute node. Activate conda environment where R and radian are installed
    5. Run radian from Terminal pane (I do see my print statement 'this is my rprofile')
    6. If I run plot(1:10, 1:10) I don't see a plot.

    The key here is that login-node/tmp/ is different from compute-node/tmp/

    My remote host is an HPC, so I don't want to do heavy computational work on the login node. I want to use a compute node. I think what is happening is that r session watcher is still looking for vscode-r plots in login-node/tmp/ but my plots are actually saved to the compute-node/tmp directory.

    Is there a way to change the tmp directory? For e.g., if I can put it in $HOME/tmp then I think this could solve my problem since $HOME is the same, whether I'm on a login or compute node?

    EDIT: indeed, I have confirmed that r session watcher works if I don't get an interactive node :)

  4. fabern commented on Mar 22, 2021

    @fabern

    I'm myself just getting started using SSH in VSCode.

    @radlinsky As an alternative to your statements:

    1. From VSCode in Windows 10, connect to linux host login node with Remote-SSH

    and:

    My remote host is an HPC, so I don't want to do heavy computational work on the login node. I want to use a compute node.

    Have you considered SSH'ing directly into the compute node with VSCode? Following: https://stackoverflow.com/a/66389686
    Does that make any difference?

  5. github-actions commented on May 22, 2022

    @github-actions

    This issue is stale because it has been open for 365 days with no activity.

  6. github-actions commented on Jun 5, 2022

    @github-actions

    This issue was closed because it has been inactive for 14 days since being marked as stale.

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

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions