positron icon indicating copy to clipboard operation
positron copied to clipboard

`RSTUDIO_PANDOC` env var is not propagated to terminal process (like for `r.rmarkdownRender`)

Open alearrigo opened this issue 1 year ago • 5 comments

Positron Version:

Positron Version: 2024.06.1 (Universal) build 27 Code - OSS Version: 1.90.0 Commit: a893e5b282612ccb2200102957ac38d3c14e5196 Date: 2024-06-26T02:08:06.673Z (5 days ago) 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

> sessioninfo::session_info()
─ Session info ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.3.2 (2023-10-31)
 os       macOS Sonoma 14.5
 system   aarch64, darwin20
 ui       X11
 language (EN)
 collate  en_US.UTF-8
 ctype    en_US.UTF-8
 tz       Europe/Rome
 date     2024-07-01
 pandoc   3.1.12.3 @ /Applications/Positron.app/Contents/Resources/app/bin/pandoc/ (via rmarkdown)

─ Packages ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 package     * version    date (UTC) lib source
 cli           3.6.3.9000 2024-06-30 [1] Github (r-lib/cli@d9febb5)
 digest        0.6.35     2024-03-11 [1] CRAN (R 4.3.1)
 evaluate      0.23       2023-11-01 [1] CRAN (R 4.3.1)
 fastmap       1.2.0      2024-05-15 [1] CRAN (R 4.3.3)
 highr         0.10       2022-12-22 [1] CRAN (R 4.3.0)
 htmltools     0.5.8.1    2024-04-04 [1] CRAN (R 4.3.1)
 knitr         1.45       2023-10-30 [1] CRAN (R 4.3.1)
 rlang         1.1.4.9000 2024-06-30 [1] Github (r-lib/rlang@cebbabf)
 rmarkdown     2.25       2023-09-18 [1] CRAN (R 4.3.1)
 sessioninfo   1.2.2      2021-12-06 [1] CRAN (R 4.3.0)
 xfun          0.42       2024-02-08 [1] CRAN (R 4.3.1)

 [1] /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library

Steps to reproduce the issue:

I'm trying to render the classic Rmd template from RStudio with a word output, saved as a .Rmd file using the "Render Document with R Markdown" command:

---
title: "Untitled"
author: "name
date: "`r Sys.Date()`"
output: word_document
---

```{r setup, include=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>.

When you click the **Knit** button 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.


That's the output:

Screenshot 2024-07-01 alle 19 39 24

Note in the lower-right, the rmd file is read as quarto. Shouldn't it be Rmarkdown? Is there some setting to flag/official extension to install or the association is automatic?

What did you expect to happen?

Rendering the doc.

Were there any error messages in the output or Developer Tools console?

rmarkdown::render("/Users/alessandroarrigo/Desktop/Senza nome.Rmd")
Error: pandoc version 1.12.3 or higher is required and was not found (see the help page ?rmarkdown::pandoc_available).
Execution halted

 *  The terminal process "/bin/zsh '-l', '-c', '/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/bin/R -e 'rmarkdown::render("/Users/alessandroarrigo/Desktop/Senza nome.Rmd")''" failed to launch (exit code: 1). 
 *  Terminal will be reused by tasks, press any key to close it. 

Checking for pandoc:

> rmarkdown::pandoc_available()
[1] TRUE
> rmarkdown::find_pandoc()
$version
[1] ‘3.1.12.3’

$dir
[1] "/Applications/Positron.app/Contents/Resources/app/bin/pandoc"
>

alearrigo avatar Jul 01 '24 17:07 alearrigo

I think the problem here is that RSTUDIO_PANDOC needs to be set in the terminal process that runs rmarkdown::render() -- we already set this in the main R session (which is why find_pandoc() works there)

jmcphers avatar Jul 01 '24 18:07 jmcphers

Related to #2723 which is another example of an env var from the main process not being propagated to a terminal process.

juliasilge avatar Jul 01 '24 18:07 juliasilge

Has the same problem

ntluong95 avatar Jul 01 '24 20:07 ntluong95

If someone wants to get unstuck in the short term, I think the solution is to install Pandoc yourself (vs. only having the version that ships inside RStudio). For example, on macOS, you might do brew install pandoc if you're a homebrew person.

jennybc avatar Jul 01 '24 22:07 jennybc

@jennybc it worked thanks!

alearrigo avatar Jul 02 '24 08:07 alearrigo

Verified Fixed

Positron Version(s) : 2024.07.0-21 OS Version(s) : MacOS 14

Test scenario(s)

RMD document renders as expected.

Note - couldn't check on Windows due to #3816

Link(s) to TestRail test cases run or created:

None

jonvanausdeln avatar Jul 09 '24 19:07 jonvanausdeln