Fix issues in rstudioapi emulation#422
Conversation
Co-authored-by: Daniel Angst <dcangst@users.noreply.github.com>
tested working on malformed files
|
@Ikuyadeu We might need a release once this PR is merged and notice users that When the feature become more stable, then we could make it |
|
Maybe off the topic but https://github.com/Ikuyadeu/vscode-R/blob/master/src/rstudioapi.ts#L306 could be removed. |
|
Still not sure if this is working properly on Windows. I just tried to install the vsix and I am getting issues. Not sure if I installed the right thing. |
|
Oh yeah looks like I installed an old one. Let me confirm. |
|
No. I'm seeing something very strange. Using the vsix file built by the CI:
Which is totally weird, since I can do: But if no It's really spinning me out. |
|
OK OK OK. I got it. It was an issue with my .Rprofile which had some old stuff in there, manually sourcing init.R. ALL GOOD. 😌 |
|
I tried the latest commit on macOS and Windows 10 VM and everything looks good so far. |
@MilesMcBain, I have the same error message on my Ubuntu. |
|
@almaceleste Check for any calls to this function in any of your session startup code and remove. |
|
@MilesMcBain, I have no source(
file.path(
Sys.getenv(
if (.Platform$OS.type == "windows") "USERPROFILE" else "HOME"
), ".vscode-R", "init.R"
)
)
options(vsc.rstudioapi = TRUE) |
|
@almaceleste |
|
@renkun-ken, thanx, it helps me. |
|
@almaceleste Good to know it works for you now.
Definitely. @MilesMcBain Would you mind updating docs so that users know how to enable it exactly? (e.g. #422 (comment) won't work) |
|
I added a bit extra to the wiki: https://github.com/Ikuyadeu/vscode-R/wiki/RStudio-addin-support#enabling-rstudio-addin-support |
Resolves the issues discussed in #421:
addins.dcffile from a package is malformed it could cause an error when trying to write the JSON to drive the addin picker. This error could cause thevsc.attachfunction to fail to run fully. This was not very common. I found only one example in{shrcts}.I added extra checks to look for malformed files, and to only select the first few columns, assuming those contain the information I want to display. The whole
update_addins_registrycall is wrapped in a try-catch so that if it throws an error it is converted to a message about the failure and the consequences.vsc.attachwill complete otherwise normally.library(tidyverse)fails due to theclipackage trying to interrogate the version of RStudio if it is available. I have put in implementations forgetVersionandversionInfothat should allow this to work in the short term.The plan is to discuss this with RStudio to see if we can get something less fragile.
Finally, to use the RStudio API emulation the user must set
options(vsc.rstudioapi = TRUE)in the .Rprofile. I have put documentation about this in the README and will add it to the wiki.Sorry for the hassles!