Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VS Code extension: Rmd does not export symbols #488

Open
artmg opened this issue Jul 21, 2024 · 8 comments
Open

VS Code extension: Rmd does not export symbols #488

artmg opened this issue Jul 21, 2024 · 8 comments
Labels

Comments

@artmg
Copy link

artmg commented Jul 21, 2024

The Quarto extension fails to provide symbols for an R Markdown document such as scratch.Rmd (content below). The issue prevents:

  • the breadcrumbs from being shown
  • the outline from being displayed
  • the Jump to symbol navigation shortcut box being populated

image

This occurs in
Positron Version: 2024.07.0 (Universal) build 21
Code - OSS Version: 1.90.0
Commit: 82b335e27545e804b7fd806db00477a6eb49951d
Date: 2024-07-09T04:32:26.804Z
Electron: 29.4.0
Chromium: 122.0.6261.156
Node.js: 20.9.0
V8: 12.2.281.27-electron.0
OS: Darwin arm64 23.5.0

Also in Quarto v1.113.0 in VS Code

If I install REditorSupport.r extension then the R Markdown document symbols appear as normal, but not in the Quarto extension.

This issue was previously raised as Positron Issue #3982 and now transcribed here at the request of @juliasilge

Code for scratch.Rmd for testing is below:

---
title: "A wonderful R Markdown document"
output:
  html_document:
    math_method: katex
---

```{r echo = FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.

Here is some math:

$1 + 1$

When you render this file, a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

```{r cars}
summary(cars) 
```

## Including Plots

You can also embed plots, for example:

```{r pressure, echo=FALSE}
plot(pressure)
```

Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
@juliasilge
Copy link
Collaborator

If you check out posit-dev/positron#3982, you will see that @artmg also observes this problem in VS Studio, not only Positron.

FWIW folks have not been able to reproduce this problem. We'll need to find a way to look at logs and/or debug what may be causing the Quarto extension not to contribute these symbols.

@juliasilge juliasilge changed the title Rmd does not export symbols VS Code extension: Rmd does not export symbols Jul 22, 2024
@cderv cderv added the vscode label Jul 22, 2024
@artmg
Copy link
Author

artmg commented Sep 5, 2024

Looking through /apps/vscode/package.json for any obvious configuration issues at my end, I also tried using files with .Qmd and .qmd extensions, but the issue remains. Unfortunately when looking through the quarto-lsp at service providers for document and workspace symbols I feel somewhat lost.

@juliasilge If it helps I can use yarn dev-vscode to perform debugging in situ – if you could suggest either

  1. what setting to use to turn on the level of logs you require (my debug console remains fairly empty for now) or
  2. where I might place any breakpoints or other tests I can perform.

Happy to supply further diagnostics if you can offer me a little direction, please.

@juliasilge
Copy link
Collaborator

Can you check on a couple of things @artmg?

  • What happens if you start Positron with no extra extensions? I believe you can do this from the command line, in the directory where your .Rmd is, via positron --disable-extensions .
  • Sounds like you are also a user of the vscode-R extension. Can you check your .Rprofile for anything that may be running in both VS Code and Positron that may be interfering? Is there a settings.json or similar that may be interfering?

@artmg
Copy link
Author

artmg commented Sep 6, 2024

Thank you for your suggestions, I had a look at the config files...

find ~ -iname "*rprofile*"
find ~ -iname "settings.json"

but I had no .RProfile and I could not find anything obvious in any relevant settings.json. However this inspired me to try the perhaps desperate option to prove if it could work

purge and start again

I uninstalled Positron AND VSCode

I purged the following folders

  • ~/Library/Application Support/Positron/
  • ~/Library/Application Support/Code/
  • ~/.positron/
  • ~/.vscode-R/
  • ~/.vscode/

just Positron - successfully see symbols

I went to Positron releases and installed Positron-2024.09.0-1.dmg

When I open the scratch.Rmd file I get symbols in the outline as hoped - 🎉

add vscode - fails in there

When I go back to try vscode:

❯ brew install visual-studio-code
❯ code --install-extension quarto.quarto
Installing extensions...
Installing extension 'quarto.quarto'...
Extension 'quarto.quarto' v1.114.0 was successfully installed.
❯ code .

I now get an empty outline with No symbols found in document 'scratch.Rmd' when I open it in vscode with quarto 😢

even dev version - fails in there too

❯ code --uninstall-extension quarto.quarto
❯ cd ..
❯ git clone [email protected]:quarto-dev/quarto.git
Cloning into 'quarto'...
[...] Receiving objects [...] done.
❯ cd quarto
Uninstalling quarto.quarto...
Extension 'quarto.quarto' was successfully uninstalled!
❯ corepack enable
❯ yarn
yarn install v1.22.22
[...]
[4/4] 🔨  Building fresh packages...
✨  Done in xx.36s.
❯ code .
❯ yarn dev-vscode
yarn run v1.22.22
$ turbo run dev --filter quarto...
[...]
quarto-vscode-editor:dev: build started...
[...]
quarto-vscode-markdownit:dev: built in xx108ms.
quarto-vscode-markdownit:dev: [vite-plugin-static-copy] Copied 7 items.

Using Run and Debug to start up a new code instance as the 'extension development host' also gives No symbols found in document 'scratch.Rmd' 😭

Good news and bad

So it's great that I got Positron itself working ok, which was my original goal – and it still works after vscode was installed. Perhaps not so great that I did not get the quarto extension in vscode to work, nor that it's not clear why not.

Should I do further tests @juliasilge to see if I can remove everything and get just the quarto extension working in vscode? Even if it means putting off trying out Positron for the time being.

@juliasilge
Copy link
Collaborator

Wow, thank you so much for sharing what you tried here @artmg! Can you clarify here for me:

I now get an empty outline with No symbols found in document 'scratch.Rmd' 😢

Do I understand you correctly that after you install VS Code, you get no symbols found in Positron?

Next question from me: what happens if you install VS Code but not the Quarto extension in VS Code? Do you get the symbols in Positron?

Another question: what happens if you install VS Code from their official installers rather than via brew?

@artmg
Copy link
Author

artmg commented Sep 6, 2024

Sorry for the ambiguity - I hope I improved it above to clarify that the failures were all in vscode with quarto. Positron is still working just fine, even after vscode is installed. Next I can try removing everything and purging files, then just installing VS Code (officially) and try the quarto extension. Likely next week now :)

@artmg
Copy link
Author

artmg commented Sep 7, 2024

Try vscode and quarto alone

and this time use the official image to install

purge and start again

  • Uninstall Positron and empty recycler
# remove vscode and stray configs
brew uninstall visual-studio-code
rm -rf ~/Library/Application Support/Positron/
rm -rf ~/Library/Application Support/Code/
rm -rf ~/.positron/
rm -rf ~/.vscode-R/
rm -rf ~/.vscode/

VS Code no extn

With NO extensions at all, you can see that the Rmd has an 'R' icon, but is recognised as Plain Text and exports no symbols, which is what one would expect
image

VS Code with Quarto extn

Installing Quarto extension does give the qmd file an icon, and both .qmd and .Rmd are recognised as Quarto language, but still no symbols can be found.
image

Positron

Fortunately when I re-install Positron, opening the Rmd inside Positron
works just fine and shows symbols both in the Outline and as breadcrumbs in the editor header
image

Summary

Upon a totally clean install...

  • Positron Version: 2024.09.0 on macOS (with ONLY it's 7 preinstalled extensions) WORKS, correctly displaying symbols, regardless of the presence of VS Code, but
  • VS Code with Quarto extension v1.114.0 FAILS, giving No symbols found in document 'scratch.Rmd' - even when Positron is not installed, nor any other extension is present.

I am happy that I can carry on using Positron now that I have a clean install, but please do ask if you'd like any further diagnostics on the VS Code Quarto extension on its own

@artmg
Copy link
Author

artmg commented Sep 7, 2024

PS: I tried to add a comment to the original posit-dev/positron#3982 but it has been locked - @juliasilge might it be worth adding a footnote in that issue, please, mentioning the resolution for Positron?

  1. uninstall any previous versions of Positron AND VS Code
  2. purge any user folders that may contain extensions or stray settings (e.g. ~/Library/Application Support/Positron/ ~/Library/Application Support/Code/ ~/.positron/ ~/.vscode-R/ ~/.vscode/ )
  3. reinstall Positron

Rmd files should now correctly show their symbols in Positron

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants