rstudio / rstudio

RStudio is an integrated development environment (IDE) for R
https://posit.co/products/open-source/rstudio/
Other
4.65k stars 1.09k forks source link

Visual editor fails to load and pandoc error with hello tutorial #13685

Closed astayleraz closed 11 months ago

astayleraz commented 11 months ago

System details

RStudio Edition : Server and workbench
RStudio Version : 2023.12.0-daily+14 and 2023.12.0-daily+8.pro1
OS Version      : ubuntu20
R Version       : 4.3.0

Steps to reproduce the problem

  1. Create a markdown, rmarkdown, or quarto file.
  2. Click to go into visual mode. or
  3. click the tutorial tab and try and run the hello world tutorial.

Describe the problem in detail

The user will just see a spinner or an error with the spinner. If you try the tutorial, you get a pandoc error.

Error: pandoc version 1.12.3 or higher is required and was not found (see the help page ?rmarkdown::pandoc_available).
Execution halted

Screenshot 2023-09-25 at 12 54 54 PM Screenshot 2023-09-25 at 12 56 06 PM

Kevin noticed the path with pandoc has changed but RSTUDIO_PANDOC shows a different path.

kevin@ip-172-98-22-79:/usr/lib/rstudio-server/bin/quarto/bin/tools/x86_64$ ll
total 291584
drwxr-xr-x 4 root root      4096 Sep 25 20:28 ./
drwxr-xr-x 3 root root      4096 Sep 25 20:27 ../
drwxr-xr-x 3 root root      4096 Sep 25 20:28 dart-sass/
-rwxr-xr-x 1 root root 113436728 May 18 17:09 deno*
drwxr-xr-x 2 root root      4096 Sep 25 20:28 deno_dom/
-rwxr-xr-x 1 root root   9261056 Oct 26  1985 esbuild*
-rwxr-xr-x 1 root root 148600824 Aug 31 20:02 pandoc*
-rwxr-xr-x 1 root root  27260184 Aug  7 16:30 typst*

Note the x86_64 suffix; I don’t think that existed before. However, RSTUDIO_PANDOC still has:

> Sys.getenv("RSTUDIO_PANDOC")
[1] "/usr/lib/rstudio-server/bin/quarto/bin/tools"

Describe the behavior you expected

Visual mode and tutorials should work and run with no issues or errors.

ronblum commented 11 months ago

Note: This also affects knitting an R Markdown file, and switching a file to visual mode will do this, as well. Checked in RStudio Desktop 2023.12.0-daily+84 on MacOS 14.

Working around this with setting the following in .Renviron: RSTUDIO_PANDOC="/Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/x86_64" resolves the tutorial and knitting, but not the visual editor spinning.

jgutman commented 11 months ago

It looks like Quarto 1.4 on macOS now places tools like pandoc into architecture-specific sub-directories, e.g. <quarto>/bin/tools/x86_64/pandoc. This has consequences for RStudio and rmarkdown since RSTUDIO_PANDOC is normally set to just <quarto>/bin/tools. Should we be updating RSTUDIO_PANDOC to point at the appropriate architecture sub-directory in RStudio, RSTUDIO_PANDOC is the way to communicate through an env var to Rmarkdown in which folder Pandoc binary is. This is widely used I believe in products (ours and probably others) to configure rmarkdown find_pandoc() using an env var. The organization to put pandoc.exe in a directory with architecture is a Quarto choice. I don't think rmarkdown should assume that this will always be the case to look for pandoc in a architecture directory. So we could indeed have a heuristic to also look in such subfolder if we don't find it in root RSTUDIO_PANDOC . However, RStudio IDE is the one communicating to rmarkdown that the pandoc.exe to use is the one bundled with Quarto, which happens to be under a architecture directory. So that is why I thought this would be something to "whom" send the info to rmarkdown to deal with.

astayleraz commented 11 months ago

If its helpful @kevinushey posted this issue with the quarto dev team here on this https://positpbc.slack.com/archives/C03E8CWNGBB/p1695678310495969

ronblum commented 11 months ago

Verified in RStudio Desktop 2023.12.0-daily+99 on MacOS 14. However, the tutorial still doesn't load in RStudio Server 2023.12.0-daily+99 on Ubuntu 20.04:

> Sys.getenv("RSTUDIO_PANDOC")
[1] "/usr/lib/rstudio-server/bin/quarto/bin/tools"

However, after setting

> Sys.setenv("RSTUDIO_PANDOC" = "/usr/lib/rstudio-server/bin/quarto/bin/tools/x86_64")

the tutorial works.

kevinushey commented 11 months ago

Does it work if you restart the R session so you get a fresh version of that environment variable?

ronblum commented 11 months ago

That was it—all set, thanks!

ronblum commented 4 months ago

QA note: Cf. rmarkdown::find_pandoc()$dir with Sys.getenv("RSTUDIO_PANDOC").