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

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

Closed
alearrigo opened this issue Jul 1, 2024 · 6 comments
Labels
bug Something isn't working lang: r

Comments

@alearrigo
Copy link

Positron Version:

Positron Version: 2024.06.1 (Universal) build 27
Code - OSS Version: 1.90.0
Commit: a893e5b
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 alearrigo added the bug Something isn't working label Jul 1, 2024
@jmcphers
Copy link
Collaborator

jmcphers commented Jul 1, 2024

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)

@juliasilge
Copy link
Contributor

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

@ntluong95
Copy link

Has the same problem

@jennybc
Copy link
Member

jennybc commented Jul 1, 2024

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.

@alearrigo
Copy link
Author

@jennybc it worked thanks!

@juliasilge juliasilge changed the title Rmarkdown files not rendering. RSTUDIO_PANDOC env var is not propagated to terminal process (like for r.rmarkdownRender) Jul 2, 2024
@juliasilge juliasilge added this to the 2024.08.0 Pre-Release milestone Jul 5, 2024
juliasilge pushed a commit that referenced this issue Jul 8, 2024
…#3856)

Several beta users have already reported trouble rendering documents
with Positron because the render tasks can't find Pandoc, even though it
ships with Positron.

This change supplies the`RSTUDIO_PANDOC` environment variable when
running packaging tasks and R Markdown rendering jobs. It's done using
the same logic we use to supply `RSTUDIO_PANDOC` to the main R session.

Addresses #3776.

### QA Notes

The embedded Pandoc is only used when there's no other Pandoc on the
`$PATH`. To test this, uninstall all your Pandocies (make sure `which
pandoc` returns nothing) first so that only the bundled Pandoc is
available.

This also touches the code that injects Pandoc into the main R session,
so make sure e.g. `rmarkdown::pandoc_version()` still works there.
@jonvanausdeln
Copy link
Contributor

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

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working lang: r
Projects
None yet
Development

No branches or pull requests

6 participants