Skip to content

Use Windows registry to find R path#252

Merged
renkun-ken merged 6 commits intoREditorSupport:masterfrom
renkun-ken:win-find-rpath
Mar 4, 2020
Merged

Use Windows registry to find R path#252
renkun-ken merged 6 commits intoREditorSupport:masterfrom
renkun-ken:win-find-rpath

Conversation

@renkun-ken
Copy link
Copy Markdown
Member

@renkun-ken renkun-ken commented Mar 2, 2020

What problem did you solve?

Closes #244

(If you do not have screenshot) How can I check this pull request?

If a Windows user installs R with default installation settings, the R path will be added to registry. So that user does not have to specify R executable in this case.

To test it, set rterm.windows to empty (now it's empty by default), run Create R Terminal and see if it could properly find R path and create a terminal with it.

Another thing to test is that if multiple versions are installed, the registry will contain multiple entries of R paths. Although the registry entry will have multiple subentries in this case, the value of the key should be the last installed version.

@renkun-ken renkun-ken changed the title WIP: Use Windows registry to find R path Use Windows registry to find R path Mar 4, 2020
@renkun-ken renkun-ken requested a review from andycraig March 4, 2020 03:56
@renkun-ken
Copy link
Copy Markdown
Member Author

I tested this on my Windows 10 VM and it works as expected.

image

To test, please download the build at https://github.com/Ikuyadeu/vscode-R/actions/runs/49221093 or see the artifacts in the details of main / build (pull_request).

@andycraig
Copy link
Copy Markdown
Collaborator

@renkun-ken I tried testing this just now on Windows 10, but no success I'm afraid.

Testing using VSIX file:

Cannot find R client.  Please check R path in preferences and reload.

Just to check, I also tested by running your win-find-rpath branch in debug mode:

Activating extension 'Ikuyadeu.r' failed: Cannot find module 'winreg'.
command 'r.createRTerm' not found

Not sure if it helps, but this is what my registry looks like:

reg

Full key is like Computer\HKEY_LOCAL_MACHINE\SOFTWARE\R-core\R\3.4.1

@ksq
Copy link
Copy Markdown

ksq commented Mar 4, 2020

I test with the VSIX at https://github.com/Ikuyadeu/vscode-R/actions/runs/49233584 and it works perfectly on my Windows 10.

My registry looks like

image

@renkun-ken
Copy link
Copy Markdown
Member Author

@andycraig We use R's InstallPath key rather than any sub-entries such as 3.4.4 or 3.6.3.
Would you like to take a look at the keys R has?

@andycraig
Copy link
Copy Markdown
Collaborator

@renkun-ken Looks like that's the issue in my case. InstallPath seems to be under 3.4.1 rather than R:

reg1

reg2

@renkun-ken
Copy link
Copy Markdown
Member Author

renkun-ken commented Mar 4, 2020

@andycraig I see. I'm not sure if newer versions of R will write to both R and R/3.x.y, or maybe it could also be caused by uninstalling the last installed version.

We are using almost the same code as in vscode-r-lsp and its default value. Therefore we are consistent with it too. If user does not have the R executable path correctly written in R/InstallPath, then user should specify path in VSCode settings for both vscode-R and vscode-r-lsp. Maybe we should make it more clear in the documentation or error message?

@andycraig
Copy link
Copy Markdown
Collaborator

@ksq Thank you for testing!

@renkun-ken Yeah, the version of R I have installed on Windows is old so that could well be it.

It worked for @ksq, and for me it displayed the appropriate error message. The README is very clear as well. I am happy with it as-is. Please merge it if you have no additional changes.

Thank you for this PR! It will make it simpler for new users.

@renkun-ken renkun-ken merged commit 3b22fbf into REditorSupport:master Mar 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Get R term path from registry in Windows

3 participants