GeezerVison is showing github.com — no code highlight in terminal · Issue #190 · REditorSupport/vscode-R
no code highlight in terminal #190DescriptionThanks for the extension. The following gif seems really nice but I didn't have code highlight in my terminal. Am I missing something?

R: 3.6.1
OS: Windows 10
VScode: 1.41.1 Activityrenkun-ken commented on Jan 16, 2020 Sorry for not making it clear in README. It is radian.
ccb580e in #184 should fix this. stevenlis commented on Jan 16, 2020 @renkun-ken Thanks! Do this requrie R Session Watcher to be turned on to use? I thought this is a R Session Watcher.. stevenlis commented on Jan 16, 2020 I am running radian now but R interactive and radian in two separate terminals. Am I missing something?

 renkun-ken commented on Jan 16, 2020 R session watcher does not require radian.
The first R interactive in your screenshot is probably created by command R: Create R terminal. It creates an R interactive terminal by running the program specified in VSCode option r.rterm.* according to your OS. By default, it is the official R terminal.
If you want to change the default terminal, you need to change the Rterm: Windows|Linux|macOS is VSCode settings or update r.rterm.* in settings.json to the path of your radian executable.
To use radian smoothly, you should also turn on r.bracketedPaste option.
If you prefer opening radian manually by typing radian command in the terminal, you could turn on r.alwaysUseActiveTerminal option so that sending selection to terminal will directly send code to active terminal rather than detect if there's an active R terminal created by vscode-R. stevenlis commented on Jan 16, 2020 I found it and set
"r.rterm.windows": "C:\\Users\\liqia\\Anaconda3\\Scripts\\radian.exe"
and then R: Run Selection/Line but get
The terminal process terminated with exit code: 2
It seems like everything is working but as long as I use it R: Run Selection/Line to run the radian.exe. I will get the error. renkun-ken commented on Jan 16, 2020 I could reproduce your error in a Windows 10 virtualbox machine.
It is caused by default R term options not supported by radian. Delete all Rterm option items in VSCode settings or append "r.rterm.option": [] to your VSCode settings.json, reload window, and radian should work.
The error does not occur under Linux and macOS, not sure why there's such different behaviors.
The same error also occurs under Linux and macOS. Maybe we should document this somewhere. stevenlis commented on Jan 16, 2020 Thanks man. It's working now. But it seems like it uses C:/Users/liqia/Anaconda3/lib/R/bin/x64/R
instead of C:\Program Files\R\R-3.6.1\bin\R.exe. I just read the radian's doc but am not clear how to change it. Would you happen to know? renkun-ken commented on Jan 16, 2020 stevenlis commented on Jan 16, 2020 Thanks. I'll take a look. Now the dataset and plot show in separate windows instead of inside vscode.

Can you reproduce this? renkun-ken commented on Jan 16, 2020 stevenlis commented on Jan 16, 2020 @renkun-ken I did and it was working before. I think it's maybe due to the change of R.exe. I change it back and now no window show up at all. I will try later. stevenlis commented on Jan 17, 2020 It was working before I change it to radian. Now I created Rprofile via

After restarting it, I get
Error in get_result(out, private$options) :
callr subprocess failed: could not start R, exited with non-zero status, has crashed or was killed
[]
exiting
Warning messages:
1: In readChar(self$inputcon, n, useBytes = TRUE) :
text connection used with readChar(), results may be incorrect
2: In readChar(self$inputcon, n, useBytes = TRUE) :
text connection used with readChar(), results may be incorrect
3: In readChar(self$inputcon, n, useBytes = TRUE) :
text connection used with readChar(), results may be incorrect
4: In readChar(self$inputcon, n, useBytes = TRUE) :
text connection used with readChar(), results may be incorrect
[Info - 10:50:45 PM] Connection to server got closed. Server will restart.
Language server exited with exit code 0
Error in get_result(out, private$options) :
callr subprocess failed: could not start R, exited with non-zero status, has crashed or was killed
Now I set "r.sessionWatcher": false and tried View() and plot() and no windows show up at all. renkun-ken commented on Jan 17, 2020 The error message comes from the languageserver and suggests that callr::r_bg() cannot start a R process to process tasks. It might be related to how callr finds R executable.
It looks like you should set r.lsp.path to the same R executable radian uses.
To enable R session watcher, you should set "r.sessionWatcher": true and append the source(...) command to ~/.Rprofile, while to disable it, you should undo both. stevenlis commented on Jan 17, 2020 I did delete .Rprofile though...
 renkun-ken commented on Jan 17, 2020 Do View() and plot() work in a plain R terminal instead of radian? renkun-ken commented on Jan 20, 2020 I'm a bit confused about the environment you are starting the R process. Would you mind posting your sessionInfo(), str(options()), and Sys.getenv() in the R process which you find problematic? stevenlis commented on Jan 20, 2020 @renkun-ken right now. No matter what I use, plot() and View() just won't work.
r$> sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.6.1 tools_3.6.1 jsonlite_1.6
r$> str(options())
List of 67
$ add.smooth : logi TRUE
$ browser :function (url, ...)
..- attr(*, "srcref")= 'srcref' int [1:8] 24 21 24 73 21 73 24 24
.. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' <environment: 0x0000017745295480>
$ browserNLdisabled : logi FALSE
$ CBoundsCheck : logi FALSE
$ check.bounds : logi FALSE
$ citation.bibtex.max : int 1
$ continue : chr "+ "
$ contrasts : Named chr [1:2] "contr.treatment" "contr.poly"
..- attr(*, "names")= chr [1:2] "unordered" "ordered"
$ defaultPackages : chr [1:6] "datasets" "utils" "grDevices" "graphics" ...
$ demo.ask : chr "default"
$ deparse.cutoff : int 60
$ device :function (...)
..- attr(*, "srcref")= 'srcref' int [1:8] 20 20 23 11 20 11 20 23
.. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' <environment: 0x0000017745295480>
$ device.ask.default : logi FALSE
$ digits : int 7
$ echo : logi TRUE
$ editor : chr "notepad"
$ encoding : chr "native.enc"
$ example.ask : chr "default"
$ expressions : int 5000
$ help.search.types : chr [1:3] "vignette" "demo" "help"
$ help.try.all.packages : logi FALSE
$ help_type : chr "html"
$ HTTPUserAgent : chr "R (3.6.1 x86_64-w64-mingw32 x86_64 mingw32)"
$ install.packages.compile.from.source: chr "interactive"
$ internet.info : int 2
$ keep.parse.data : logi TRUE
$ keep.parse.data.pkgs : logi FALSE
$ keep.source : logi TRUE
$ keep.source.pkgs : logi FALSE
$ locatorBell : logi TRUE
$ mailer : chr "mailto"
$ matprod : chr "default"
$ max.print : int 99999
$ menu.graphics : logi FALSE
$ na.action : chr "na.omit"
$ nwarnings : int 50
$ OutDec : chr "."
$ page_viewer :function (url, ...)
..- attr(*, "srcref")= 'srcref' int [1:8] 26 25 26 78 25 78 26 26
.. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' <environment: 0x0000017745295480>
$ pager : chr "internal"
$ papersize : chr "letter"
$ PCRE_limit_recursion : logi NA
$ PCRE_study : int 10
$ PCRE_use_JIT : logi TRUE
$ pdfviewer : chr "C:/Program Files/R/R-3.6.1/bin/x64/open.exe"
$ pkgType : chr "both"
$ prompt : chr "\033[34mr$>\033[0m "
$ rchitect.py_tools :<environment: 0x000001774778dea8>
$ repos : Named chr "@CRAN@"
..- attr(*, "names")= chr "CRAN"
$ scipen : num 0
$ show.coef.Pvalues : logi TRUE
$ show.error.messages : logi TRUE
$ show.signif.stars : logi TRUE
$ str :List of 3
..$ strict.width: chr "no"
..$ digits.d : int 3
..$ vec.len : int 4
$ str.dendrogram.last : chr "`"
$ stringsAsFactors : logi TRUE
$ timeout : num 60
$ ts.eps : num 1e-05
$ ts.S.compat : logi FALSE
$ unzip : chr "internal"
$ useFancyQuotes : logi FALSE
$ verbose : logi FALSE
$ viewer :function (url, ...)
..- attr(*, "srcref")= 'srcref' int [1:8] 25 20 25 73 20 73 25 25
.. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' <environment: 0x0000017745295480>
$ vscodeR :<environment: 0x0000017745ce2948>
$ warn : num 0
$ warning.length : int 1000
$ width : int 207
$ windowsTimeouts : int [1:2] 100 500
r$> Sys.getenv()
ALLUSERSPROFILE C:\ProgramData
APPDATA C:\Users\liqia\AppData\Roaming
asl.log Destination=file
COLORTERM truecolor
CommonProgramFiles C:\Program Files\Common Files
CommonProgramFiles(x86) C:\Program Files (x86)\Common Files
CommonProgramW6432 C:\Program Files\Common Files
COMPUTERNAME DESKTOP-2AE5U2K
ComSpec C:\WINDOWS\system32\cmd.exe
DASHLANE_DLL_DIR C:\Users\liqia\AppData\Roaming\Dashlane\6.1907.0.17833\bin\Firefox_Extension\{442718d9-475e-452a-b3e1-fb1ee16b8e9f}\components;C:\Users\liqia\AppData\Roaming\Dashlane\6.1907.0.17833\ucrt;C:\Users\liqia\AppData\Roaming\Dashlane\6.1907.0.17833\bin\Qt;C:\Users\liqia\AppData\Roaming\Dashlane\6.1907.0.17833\bin\Ssl
DriverData C:\Windows\System32\Drivers\DriverData
GEODA_GDAL_DATA C:\Program Files\GeoDa Software\data
GEODA_OGR_DRIVER_PATH C:\Program Files\GeoDa Software
graphviz C:\Users\liqia\Anaconda3\Library\bin\graphviz
HOME C:\Users\liqia\Documents
HOMEDRIVE C:
HOMEPATH \Users\liqia
LANG en_US.UTF-8
LOCALAPPDATA C:\Users\liqia\AppData\Local
LOGONSERVER \\DESKTOP-2AE5U2K
MSYS2_ENV_CONV_EXCL R_ARCH
NUMBER_OF_PROCESSORS 8
OneDrive C:\Users\liqia\OneDrive
OneDriveConsumer C:\Users\liqia\OneDrive
OS Windows_NT
pandoc C:\Users\liqia\AppData\Local\Pandoc\Pandoc
PATH C:\Program
Files\R\R-3.6.1\bin\x64;C:\Perl64\site\bin;C:\Perl64\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program
Files (x86)\Calibre2\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program
Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common
Files\Intel\WirelessCommon\;C:\Program
Files\Git\cmd;C:\Users\liqia\Anaconda3;C:\Users\liqia\Anaconda3\Library\mingw-w64\bin;C:\Users\liqia\Anaconda3\Library\usr\bin;C:\Users\liqia\Anaconda3\Library\bin;C:\Users\liqia\Anaconda3\Scripts;C:\Users\liqia\AppData\Local\Microsoft\WindowsApps;C:\Users\liqia\AppData\Roaming\Dashlane\5.13.0.20992\bin\Firefox_Extension\{442718d9-475e-452a-b3e1-fb1ee16b8e9f}\components;C:\Users\liqia\AppData\Roaming\Dashlane\5.13.0.20992\ucrt;C:\Users\liqia\AppData\Local\atom\bin;C:\Users\liqia\AppData\Local\Programs\MiKTeX
2.9\miktex\bin\x64\;C:\Users\liqia\AppData\Roaming\Dashlane\5.15.0.21720\bin\Firefox_Extension\{442718d9-475e-452a-b3e1-fb1ee16b8e9f}\components;C:\Users\liqia\AppData\Roaming\Dashlane\5.15.0.21720\ucrt;C:\Users\liqia\AppData\Local\GitHubDesktop\bin;C:\Users\liqia\AppData\Local\Programs\Microsoft
VS Code\bin;C:\Program Files
(x86)\Scapple;C:\Users\liqia\AppData\Local\Microsoft\WindowsApps;C:\Users\liqia\AppData\Roaming\Dashlane\6.1907.0.17833\bin\Firefox_Extension\{442718d9-475e-452a-b3e1-fb1ee16b8e9f}\components;C:\Users\liqia\AppData\Roaming\Dashlane\6.1907.0.17833\ucrt;C:\Users\liqia\AppData\Roaming\Dashlane\6.1907.0.17833\bin\Qt;C:\Users\liqia\AppData\Roaming\Dashlane\6.1907.0.17833\bin\Ssl;C:\Users\liqia\AppData\Local\Pandoc\;;c:\users\liqia\anaconda3\lib\site-packages\pywin32_system32
PATHEXT .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROCESSOR_ARCHITECTURE AMD64
PROCESSOR_IDENTIFIER Intel64 Family 6 Model 142 Stepping 10, GenuineIntel
PROCESSOR_LEVEL 6
PROCESSOR_REVISION 8e0a
ProgramData C:\ProgramData
ProgramFiles C:\Program Files
ProgramFiles(x86) C:\Program Files (x86)
ProgramW6432 C:\Program Files
PSModulePath C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
PUBLIC C:\Users\Public
R_ARCH /x64
R_COMPILED_BY gcc 4.9.3
R_DOC_DIR C:\Program Files\R\R-3.6.1\doc
R_HOME C:/Program Files/R/R-3.6.1
R_INCLUDE_DIR C:\Program Files\R\R-3.6.1\include
R_LIBS_USER C:\Users\liqia\Documents/R/win-library/3.6
R_SHARE_DIR C:\Program Files\R\R-3.6.1\share
R_USER C:\Users\liqia\Documents
RADIAN_VERSION 0.4.4
SESSIONNAME Console
SystemDrive C:
SystemRoot C:\WINDOWS
TEMP C:\Users\liqia\AppData\Local\Temp
TERM_PROGRAM vscode
TERM_PROGRAM_VERSION 1.41.1
TMP C:\Users\liqia\AppData\Local\Temp
USERDOMAIN DESKTOP-2AE5U2K
USERDOMAIN_ROAMINGPROFILE DESKTOP-2AE5U2K
USERNAME liqia
USERPROFILE C:\Users\liqia
windir C:\WINDOWS
renkun-ken commented on Jan 20, 2020 Combined with the VSCode settings you post at #195, (I guess all above info and VSCode settings are effective at the same time?), it looks like you sourced vscode-R session watcher script init.R (because you have vscodeR option set in R, and viewer, browser, device replaced by sourcing the script) while session watcher is disabled ("r.sessionWatcher": false). randy3k/radian#139 is caused by this too.
You need to remove the source(...) line in your ~/.Rprofile and .Rprofile (if any) in working directory AND disable r.sessionWatcher in VSCode, and restart a session. Currently, if VSCode session watcher script init.R is sourced, then all interactive R session will require the use of VSCode session watcher in VSCode, or the plot and viewer will not be captured.
vignette() calls browser, so it won't work if r.sessionWatcher is not enabled either.
stevenlis commented on Jan 20, 2020 @renkun-ken I don't think I have a ~/.Rprofile, is there any command I can run to find its path? renkun-ken commented on Jan 20, 2020 You may try the following R code:
file.edit("~/.Rprofile")
file.edit(".Rprofile")
You may start a new R process with C:\...\R.exe --vanilla and see. This disables all profile and not restoring any history. stevenlis commented on Jan 20, 2020 Indeed, I don't have it
 renkun-ken commented on Jan 20, 2020 If you are sure that no .Rprofile exists as ~/.Rprofile and .Rprofile, then I guess it might come from .RData when your session restores history data it restores all options.
You may remove .RData in your working directory and see. stevenlis commented on Jan 20, 2020 Ok, I finally found out that I have a Rprofile file under C:\Program Files\R\R-3.6.1\library\base\R.

I added the following line when enabling sessionWatcher. I removed it and now everything works as expected.
source(file.path(if (.Platform$OS.type == "windows") file.path(Sys.getenv("HOMEDRIVE"), Sys.getenv("HOMEPATH")) else Sys.getenv("HOME"), ".vscode-R", "init.R"))
@renkun-ken Thanks a lot. ChristopheRoyer21 commented on Jan 27, 2020 I have
I could reproduce your error in a Windows 10 virtualbox machine.
It is caused by default R term options not supported by radian. Delete all Rterm option items in VSCode settings or append "r.rterm.option": [] to your VSCode settings.json, reload window, and radian should work.
The error does not occur under Linux and macOS, not sure why there's such different behaviors.
The same error also occurs under Linux and macOS. Maybe we should document this somewhere.
I did something like this to enable Radian because I could, and it seems to work. However, everytime I write a line in Radian, it directly gets delete so I don't even have time to see the result. Any idea why it's doing this? renkun-ken commented on Jan 27, 2020 ChristopheRoyer21 commented on Jan 27, 2020 @renkun-ken Well, unfortunately, I cannot anymore since the problem got solved by itself. I have no idea what happens. I'm new to Radian so I probably changed some options without noticing it renkun-ken commented on Jan 30, 2020 Closing now. If it stops working again, please feel free to reopen.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|