question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Session watcher not attaching R and not showing plots

See original GitHub issue

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 😃

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
radlinskycommented, Feb 11, 2021

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 😃

0reactions
github-actions[bot]commented, Jun 5, 2022

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Session Watcher does not show graphs · Issue #272 - GitHub
I do see a png for the graph stored in the PID folder within the .vscode/vscod-R folder though. So the problem seem to...
Read more >
How to show R graph from visual studio code - Stack Overflow
Session watcher is cool and useful. Is it normal that plotting does not work when I open R terminal from inside bash in...
Read more >
Writing R in VSCode: Interacting with an R session - Kun Ren
Looks like you did't enable r.sessionWatcher. You should set "r.sessionWatcher": true in vscode settings and reload vscode, then run command R: ...
Read more >
Chapter 2 Base R Plotting Basics | Introduction to R for Natural ...
IMPORTANT NOTE: If you did not attend the sessions corresponding to Chapter 1, ... The graphics device is the area in which a...
Read more >
Setting up R in Visual Studio Code · Markov Wanderer
Then make the following changes: enable R Bracketed Paste, R Session Watcher, and R: Always Use ActiveTerminal. Now we want to make plots...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found