positron
positron copied to clipboard
?? or help.search() doesn't work for R
System details:
Windows 11
Positron and OS details:
Positron Version: 2024.08.0 (system setup) build 24 Code - OSS Version: 1.91.0 Commit: d1012cc6f36088bac24a16dcfd1b55d026b239c1 Date: 2024-08-09T03:33:00.069Z Electron: 29.4.0 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Windows_NT x64 10.0.22631
Interpreter details:
R 4.4.1
Describe the issue:
The ?? or help.search() command returns all vignettes rather than only those that match the pattern.
Steps to reproduce the issue:
- Switch to the R console
- Try
??plot - All command vignettes A-Z are shown, rather than only plot-related vignettes.
Expected or desired behavior:
- The ?? and help.search() commands work properly, as in RStudio.
- Even better, add an input to the help pane as suggested in #422.
Were there any error messages in the UI, Output panel, or Developer Tools console?
No
I think I identified the bug. While the R port is 27692, the help pane accesses the "proxy port" of 44051 after 127.0.0.1. I manually accessed http://127.0.0.1:27692/doc/html/Search?objects=1&port=27692 and it worked fine.
It may therefore be worthwhile to check r_help.rs in ark, where it deals with proxy ports and r ports. I'm guessing there's a failure to start the proxy server related to commit https://github.com/posit-dev/ark/commit/77203e6f29a254bb635a713c7911c8c71fc74b93
Thank you for the report @kv9898! I am able to repro this on macOS with Positron
Here is the top of the result of ??plot in RStudio for comparison:
This does seem to affect the results: help.search("", package = "stats"). I noticed another issue where any additional help.search calls after the first one don't seem to have any effect.
Related to https://github.com/posit-dev/positron/issues/429.
Is there any temporary fix by any chance? Currently I rely on accessing the non-proxy help page on my external browser which is quite frustrating.
@kv9898 unfortunately we don't have a workaround right now, no. 😕 This issue is in triage right now so we'll soon decide when we can work on it; we may be able to address it together with #3753.
Thank you!
I spent a little bit of time on this today and wanted to pull out something that was mentioned earlier. The URLs for these results are like: http://127.0.0.1:30580/doc/html/Search?objects=1&port=30580. It always uses objects=1 no matter what you search AFAICT.
Here is where I maybe embarrass myself but admit that I have no idea what a port in a query string means. FWIW our URL munging in handle_show_help_url() currently replaces the first (real?) port with the proxy port but it does not do anything to the port query parameter. I did a quick test of whether replacing both would fix this but it does not.
Thank you so much for looking into this! From my experience, replace the first (proxy) port with the original port in the end would uncover the original link, which could be opened in an external browser (although this misses the whole point of the proxy server). Nevertheless, this seems to mean that the objects=1 is fine as this is what the original link always use.
I spent a little bit of time on this today and wanted to pull out something that was mentioned earlier. The URLs for these results are like: http://127.0.0.1:30580/doc/html/Search?objects=1&port=30580. It always uses
objects=1no matter what you search AFAICT.Here is where I maybe embarrass myself but admit that I have no idea what a port in a query string means. FWIW our URL munging in
handle_show_help_url()currently replaces the first (real?) port with the proxy port but it does not do anything to theportquery parameter. I did a quick test of whether replacing both would fix this but it does not.
Here is some info on what RStudio does:
https://github.com/rstudio/rstudio/blob/e30b33bca603feeb6552ba96d5f720d6a25497c1/src/cpp/session/modules/SessionHelp.cpp#L102-L103
The port as a query parameter is used by R help for state management in its help server.
Fantastic! If this is complicated to implement in Positron, here's a temporary fix that could serve in the short term. This could also serve as a temporary fix to #3738. I noted that doc/html/SearchOn.html is a built-in search engine for R. We can set this as the temporary home page for the help panel for R before a proper page is created. Here is a reproducible demo:
- In the R console of positron, run
??plot, note the help page is not displayed properly. - In developer tools, find the PositronHelpService log and note the original port:
In my case, the original port is 31490
- In the R console, type
http://127.0.0.1:[OriginalPort]/doc/html/SearchOn.htmland hit enter. - Select "Open in Viewer Pane"
- A functioning search portal appears in the viewer.
- Search for plot and the results are displayed properly:
~~Looks like what we need to do is munge the content of the result, like RStudio does here:~~
~~https://github.com/rstudio/rstudio/blob/e30b33bca603feeb6552ba96d5f720d6a25497c1/src/cpp/session/modules/SessionHelp.cpp#L147~~
This was not right but I did figure out the real problem!
Thank you so much @juliasilge ! I tried your version of ark and both ?? and help.search() are working now (making my life A LOT easier)! There is still one little glitch at the moment that is easy to fix - if two ?? commands are executed consecutively, the last one is not displayed. This can be replicated by:
- run
??cat(displayed normally) - run
??dog(we are stuck at the cat page)
I think this is because the url doesn't change, therefore the page is not refreshed. A manual refresh of the help pane should be able fix it. I manually refreshed it via an external browser and the new help page is displayed normally.
I opened up https://github.com/posit-dev/positron/issues/4484 to track the remaining issue with refreshing the page.
QA Notes
After https://github.com/posit-dev/ark/pull/484 and then we bump ark, we should observe:
- All requests for help that do not use query strings, like
?lm, should still work well - Requests for help that do use query strings, like
??cat, should now also work well
Thank you so much!
Verified Fixed
Positron Version(s) : 2024.08.0-77
OS Version : OSX
Test scenario(s)
Verified with initial filing instructions.
Link(s) to TestRail test cases run or created: N/A