Skip to content

Cannot render .rmd missing pandoc #969

Closed as not planned
Closed as not planned

Description

@timo-berg

Describe the bug
I'm trying to render a simple .Rmd file in VSCode but it keeps telling me
Error: pandoc version 1.12.3 or higher is required and was not found (see the help page ?rmarkdown::pandoc_available).

To Reproduce
For testing purposes I tried to render a markdown with only one cell

1+1

with the same result.
When I try to render the same Markdown in RStudio it works without problems. Pandoc is installed under /usr/local/bin/pandoc and executing pandoc -v shows the correct version. When I open a radian shell in VSCode and type rmarkdown::pandoc_version() it also shows the correct version.
The command that VSCode executes it
rmarkdown::render('[path to file]/Chap04.Rmd', encoding = 'UTF-8')

Expected behavior
VSCode should render the markdown just as RStudio does.

Environment (please complete the following information):

  • OS: macOS
  • VSCode Version: 1.64.0
  • R Version: 4.1.2
  • vscode-R version: 2.3.6
  • pandoc version: 2.17.1.1

Additional context
I tried the various other solutions to this problem such as setting the RSTUDIO_PANDOC variable but without any luck.

Activity

  1. eitsupi commented on Feb 5, 2022

    @eitsupi
    Member

    The command that VSCode executes it
    rmarkdown::render('[path to file]/Chap04.Rmd', encoding = 'UTF-8')

    What happens if you run the same command from the R console?

  2. shrektan commented on Feb 5, 2022

    @shrektan
    Contributor

    One simple solution is to copy the pandoc binary bundled in RStudio to /usr/local/bin.

    In short:

    1. Open RStudio IDE
    2. Execute file.copy(rmarkdown::pandoc_exec(), "/usr/local/bin/pandoc", overwrite = TRUE)
  3. timo-berg commented on Feb 7, 2022

    @timo-berg
    Author

    The command that VSCode executes it
    rmarkdown::render('[path to file]/Chap04.Rmd', encoding = 'UTF-8')

    What happens if you run the same command from the R console?

    This works! I also found out that if I run a code chunk and then try to execute rmarkdown::pandoc_version(), it doesn't find pandoc (i.e. it outputs "0"). Somehow the code chunk execution opens a different kind of R terminal that doesn't find pandoc?
    I use radian installed via homebrew.
    image

  4. shrektan commented on Feb 10, 2022

    @shrektan
    Contributor

    Have you read my comment above?

    Does coping the pandoc binary work?

    I'll explain a little bit:

    RStudio IDE will bundle a pandoc binary with itself. So, RStudio can find the pandoc execuable while r or radian can't. Just copy that binary to where r and radian can find will fix your issue, in my opinion.

  5. timo-berg commented on Feb 10, 2022

    @timo-berg
    Author

    Sorry yes, I tried that but it didn't change anything. The binary was also already present in the bin folder.

  6. gowerc commented on Feb 12, 2022

    @gowerc
    Contributor

    I'm wondering if this is a .bash_profile vs .bashrc issue ? As in I'm wondering if @timo-berg has defined their pandoc PATH as part of the .bash_profile but that its not going loaded in vscode-r's call to R / rmarkdown?

    Doing some googling it looks like rmarkdown looks for the value of RSTUDIO_PANDOC to find pandoc if its not on your PATH. A simple solution in theory then would be to add

    RSTUDIO_PANDOC=/path/to/pandoc
    

    in a .Renviron file in the root your project (or in the global Renviron file if you have root access).

    (source: https://stackoverflow.com/questions/28432607/pandoc-version-1-12-3-or-higher-is-required-and-was-not-found-r-shiny/29710643#29710643)

  7. timo-berg commented on Feb 15, 2022

    @timo-berg
    Author

    Thanks that solved the issue!
    If anybody else has this issue:
    Set Settings > R > Rmarkdown > Knit: Command to
    Sys.setenv(RSTUDIO_PANDOC="--path to pandoc"); rmarkdown::render
    I'm still a bit confused because I was able to knit my rmarkdowns without issues before and am not sure what caused it to crash but it is resolved.
    Thanks to all!

  8. marcel-goldschen-ohm commented on Sep 2, 2022

    @marcel-goldschen-ohm

    I am not super familiar with R or .Rmd files, but after installing r-essentials and r-rmarkdown via conda, then in VS Code settings editing the R path to point to the conda installation, whenever I try to knit a .Rmd file I get the error
    Error: pandoc version 1.12.3 or higher is required and was not found (see the help page ?rmarkdown::pandoc_available).
    Unfortunately, changing the Knit: Command to:
    Sys.setenv(RSTUDIO_PANDOC="my/path/to/pandoc"); rmarkdown::render
    where my/path/to/pandoc is the path to pandoc in my conda environment as suggested by @timo-berg did not solve the issue for me.
    I also tried installing the language server, radian and httpgd as recommended in https://code.visualstudio.com/docs/languages/r, but this also did not solve this problem.
    I'm running VS Code 1.71.0 with the R Extension installed and R 4.1.3 installed via conda on MacOS 12.5.1.
    Any suggestions for anything else I could try to get .Rmd files working in VS Code?

  9. marcel-goldschen-ohm commented on Sep 2, 2022

    @marcel-goldschen-ohm

    Just to add to the above, pandoc is found by R:

    > rmarkdown::pandoc_available()
    [1] TRUE
    
    > rmarkdown::find_pandoc()
    $version
    [1] ‘2.19.2’
    
  10. marcel-goldschen-ohm commented on Sep 2, 2022

    @marcel-goldschen-ohm

    Ok, few more pieces of info specific to VS Code:

    • In the default R terminal in VS Code, rmarkdown::find_pandoc() fails to find pandoc. If I exit R, then activate the conda environment in which I have R installed, then boot R again, then pandoc is found as above. Thus, there may be some sort of issue with having R in a conda environment? I have set the R path to that in the conda environment, but do I need to do something else to get VS Code to automatically correctly use this version of R?
    • After setting the R terminal to use the appropriate conda environment, the knit button in VS Code for .Rmd files ONLY works if the setting R > Rmarkdown > Knit: Use Background Process is unselected. Probably whatever background process is spun up is using the default R environment that cannot find pandoc? Any way to figure out which R this is?
    • Even with the R terminal using the correct conda environment and background knitting turned off (which successfully produces an HTML file upon clicking the knit button), the preview button still fails with the same pandoc version error as described before. Seems that preview probably spins up a background process by default instead of using the current R terminal regardless of the Use Background Process setting?
  11. dereckmezquita commented on Oct 3, 2022

    @dereckmezquita

    Commenting to lend a hand to others who might encounter a similar issue with this in the future.

    TLDR

    Custom Rmd yaml commands overwrite all other; to get knitting working in VSCode with a custom command and the RStudio version of pandoc modify your command as such:

    ---
    output: github_document
    knit: (function(inputFile, encoding) {
            Sys.setenv(RSTUDIO_PANDOC='/Applications/RStudio.app/Contents/MacOS/quarto/bin');
            rmarkdown::render(inputFile,
                            encoding=encoding, 
                            output_file=file.path(dirname(inputFile), "README.md")) })
    ---

    Explanation

    I am using VSCode for my R work and wanted to knit a document. First I ran into the issue mentioned here that pandoc cannot be found so I installed pandoc via conda. This worked perfectly and I could now click the knit button in VSCode and knit my document.

    I later noticed there were differences in the products from RStudio knits to VSCode knits. For example footnotes were not rendering.

    I would write in Rmd:

    Some text here and then a footnote^[Some text]

    The result in RStudio knit would be:

    Some text here and then a footnote[^1]
    
    [^1]: [Some text]

    However in VSCode result would be:

    Some text here and then a footnote[1]
    
    [1] [Some text]

    There were other differences as well this is why I investigated. I noticed my knit commands being executed were:

    # studio
    /Applications/RStudio.app/Contents/MacOS/quarto/bin/pandoc +RTS -K512m -RTS 03-06-terraform-and-docker.knit.md --to gfm-yaml_metadata_block --from markdown+autolink_bare_uris+tex_math_single_backslash --output ./03-06-terraform-and-docker.md --template /opt/homebrew/lib/R/site-library/rmarkdown/rmarkdown/templates/github_document/resources/default.md '--webtex=https://latex.codecogs.com/png.image?%5Cdpi%7B110%7D&space;%5Cbg_white&space;' 
    /Applications/RStudio.app/Contents/MacOS/quarto/bin/pandoc +RTS -K512m -RTS ./03-06-terraform-and-docker.md --to html4 --from gfm --output ./03-06-terraform-and-docker.html --standalone --self-contained --highlight-style pygments --template /opt/homebrew/lib/R/site-library/rmarkdown/rmarkdown/templates/github_document/resources/preview.html --variable 'github-markdown-css:/opt/homebrew/lib/R/site-library/rmarkdown/rmarkdown/templates/github_document/resources/github.css' --metadata pagetitle=PREVIEW '--webtex=https://latex.codecogs.com/png.image?%5Cdpi%7B110%7D&space;%5Cbg_white&space;' 
    
    # vscode
    /Users/neurox1/Tools/miniconda3/bin/pandoc +RTS -K512m -RTS 03-06-terraform-and-docker.knit.md --to gfm --from markdown+autolink_bare_uris+tex_math_single_backslash --output ./03-06-terraform-and-docker.md --template /opt/homebrew/lib/R/site-library/rmarkdown/rmarkdown/templates/github_document/resources/default.md '--webtex=https://latex.codecogs.com/png.image?%5Cdpi%7B110%7D&space;%5Cbg_white&space;' 
    /Users/neurox1/Tools/miniconda3/bin/pandoc +RTS -K512m -RTS ./03-06-terraform-and-docker.md --to html4 --from gfm --output ./03-06-terraform-and-docker.html --standalone --self-contained --highlight-style pygments --template /opt/homebrew/lib/R/site-library/rmarkdown/rmarkdown/templates/github_document/resources/preview.html --variable 'github-markdown-css:/opt/homebrew/lib/R/site-library/rmarkdown/rmarkdown/templates/github_document/resources/github.css' --metadata pagetitle=PREVIEW '--webtex=https://latex.codecogs.com/png.image?%5Cdpi%7B110%7D&space;%5Cbg_white&space;'

    These were indeed using different pandoc versions/executables.

    I uninstalled conda pandoc and tried running again; but failure as VSCode knit cannot find pandoc.

    Nothing worked, even setting env variables etc and even setting the knit command as stated in this thread in the VSCode settings.

    I noticed that the command being executed was actually the custom command I set in my Rmd yaml; which overwrites any other and modified it to this:

    ---
    output: github_document
    knit: (function(inputFile, encoding) {
            Sys.setenv(RSTUDIO_PANDOC='/Applications/RStudio.app/Contents/MacOS/quarto/bin');
            rmarkdown::render(inputFile,
                            encoding=encoding, 
                            output_file=file.path(dirname(inputFile), "README.md")) })
    ---
  12. ElianHugh commented on Oct 4, 2022

    @ElianHugh
    Collaborator

    Thank you for digging into this @dereckdemezquita! will have to check what's going on with the pandoc path setting -- it should be picked up by node (but obviously something weird is going on)

  13. tiubenedict commented on Oct 13, 2022

    @tiubenedict

    Just adding that the path for my pandoc was in /Applications/RStudio.app/Contents/MacOS/quarto/bin/tools

  14. JoeHelbing commented on Jan 21, 2023

    @JoeHelbing

    Commenting to lend a hand to others who might encounter a similar issue with this in the future.

    TLDR

    Custom Rmd yaml commands overwrite all other; to get knitting working in VSCode with a custom command and the RStudio version of pandoc modify your command as such:

    ---
    output: github_document
    knit: (function(inputFile, encoding) {
            Sys.setenv(RSTUDIO_PANDOC='/Applications/RStudio.app/Contents/MacOS/quarto/bin');
            rmarkdown::render(inputFile,
                            encoding=encoding, 
                            output_file=file.path(dirname(inputFile), "README.md")) })
    ---
    

    Explanation

    I am using VSCode for my R work and wanted to knit a document. First I ran into the issue mentioned here that pandoc cannot be found so I installed pandoc via conda. This worked perfectly and I could now click the knit button in VSCode and knit my document.

    I later noticed there were differences in the products from RStudio knits to VSCode knits. For example footnotes were not rendering.

    I would write in Rmd:

    Some text here and then a footnote^[Some text]
    

    The result in RStudio knit would be:

    Some text here and then a footnote[^1]
    
    [^1]: [Some text]

    However in VSCode result would be:

    Some text here and then a footnote[1]
    
    [1] [Some text]

    There were other differences as well this is why I investigated. I noticed my knit commands being executed were:

    # studio
    /Applications/RStudio.app/Contents/MacOS/quarto/bin/pandoc +RTS -K512m -RTS 03-06-terraform-and-docker.knit.md --to gfm-yaml_metadata_block --from markdown+autolink_bare_uris+tex_math_single_backslash --output ./03-06-terraform-and-docker.md --template /opt/homebrew/lib/R/site-library/rmarkdown/rmarkdown/templates/github_document/resources/default.md '--webtex=https://latex.codecogs.com/png.image?%5Cdpi%7B110%7D&space;%5Cbg_white&space;' 
    /Applications/RStudio.app/Contents/MacOS/quarto/bin/pandoc +RTS -K512m -RTS ./03-06-terraform-and-docker.md --to html4 --from gfm --output ./03-06-terraform-and-docker.html --standalone --self-contained --highlight-style pygments --template /opt/homebrew/lib/R/site-library/rmarkdown/rmarkdown/templates/github_document/resources/preview.html --variable 'github-markdown-css:/opt/homebrew/lib/R/site-library/rmarkdown/rmarkdown/templates/github_document/resources/github.css' --metadata pagetitle=PREVIEW '--webtex=https://latex.codecogs.com/png.image?%5Cdpi%7B110%7D&space;%5Cbg_white&space;' 
    
    # vscode
    /Users/neurox1/Tools/miniconda3/bin/pandoc +RTS -K512m -RTS 03-06-terraform-and-docker.knit.md --to gfm --from markdown+autolink_bare_uris+tex_math_single_backslash --output ./03-06-terraform-and-docker.md --template /opt/homebrew/lib/R/site-library/rmarkdown/rmarkdown/templates/github_document/resources/default.md '--webtex=https://latex.codecogs.com/png.image?%5Cdpi%7B110%7D&space;%5Cbg_white&space;' 
    /Users/neurox1/Tools/miniconda3/bin/pandoc +RTS -K512m -RTS ./03-06-terraform-and-docker.md --to html4 --from gfm --output ./03-06-terraform-and-docker.html --standalone --self-contained --highlight-style pygments --template /opt/homebrew/lib/R/site-library/rmarkdown/rmarkdown/templates/github_document/resources/preview.html --variable 'github-markdown-css:/opt/homebrew/lib/R/site-library/rmarkdown/rmarkdown/templates/github_document/resources/github.css' --metadata pagetitle=PREVIEW '--webtex=https://latex.codecogs.com/png.image?%5Cdpi%7B110%7D&space;%5Cbg_white&space;'

    These were indeed using different pandoc versions/executables.

    I uninstalled conda pandoc and tried running again; but failure as VSCode knit cannot find pandoc.

    Nothing worked, even setting env variables etc and even setting the knit command as stated in this thread in the VSCode settings.

    I noticed that the command being executed was actually the custom command I set in my Rmd yaml; which overwrites any other and modified it to this:

    ---
    output: github_document
    knit: (function(inputFile, encoding) {
            Sys.setenv(RSTUDIO_PANDOC='/Applications/RStudio.app/Contents/MacOS/quarto/bin');
            rmarkdown::render(inputFile,
                            encoding=encoding, 
                            output_file=file.path(dirname(inputFile), "README.md")) })
    ---
    

    Adding this to the R > Rmarkdown > Knit: Command extension settings in VScode worked for me, but it outputs everything in the README.md format.

    Is there a way to vary it dynamically to output as PDF or HTML by Rmd output: type?

  15. dereckmezquita commented on Jan 21, 2023

    @dereckmezquita

    @JoeHelbing not sure what you meant but this might help: https://pkgs.rstudio.com/rmarkdown/reference/render.html

    The output type gets read by the yaml above the call to rmarkdown::render.

  16. tongyaop commented on Aug 10, 2023

    @tongyaop

    Unfortunately, none of these have worked for me. I tried:

    1. in rmd yaml section, added
      knit: (function(inputFile, encoding) { Sys.setenv(RSTUDIO_PANDOC="C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools"); rmarkdown::render(inputFile, encoding=encoding, output_file=file.path(dirname(inputFile), "README.md")) })

    2. In vscode > settings> R> Rmarkdown > knit::Command
      Sys.setenv(RSTUDIO_PANDOC="C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools"); rmarkdown::render

    3. In terminal (Windows command prompt):
      set RSTUDIO_PANDOC "C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools"

    I restarted vscode session every time I made these changes.

  17. pokwir commented on Aug 17, 2023

    @pokwir

    Installing Pandoc using homebrew solved my problem. brew install pandoc

  18. snail123815 commented on Dec 6, 2023

    @snail123815

    I am running R using vscode in a conda environment of a remote server.

    I notice that the PATH in the vscode interactive R terminal does not include the necessary environment path. I came up with this solution. Here is my settings.json file.

    {
        "r.rpath.linux": "/path/to/myenv/bin/R",
        "r.rterm.linux": "/path/to/myenv/bin/R",
        "r.rmarkdown.knit.command": "Sys.setenv(PATH=paste(\"/path/to/myenv/bin\", Sys.getenv(\"PATH\"), sep=\":\")); rmarkdown::render",
    }
  19. abhilesh commented on Dec 2, 2024

    @abhilesh

    Just adding to this that I am facing a similar problem on M4 Pro. I do not have administrative rights on this machine and hence installed pandoc via conda into a user-writable directory ($HOME).

    I am on VS Code v1.95.3, radian v0.6.13 and R v4.4.2

    The pandoc installation is available inside of the radian R terminal -

    r$> rmarkdown::find_pandoc()
    $version
    [1] ‘3.5’
    
    $dir
    [1] "$HOME/anaconda3/bin"
    
    
    r$> rmarkdown::pandoc_available()
    [1] TRUE
    
    r$>

    I can knit documents with rmarkdown::render("DEG_analysis/geneset_overlap.Rmd") but when I trying knitting the document with the VS Code's knit button, it cannot find the pandoc executable and results in the following error -

    [VSC-R] geneset_overlap.Rmd process started
    Error: pandoc version 1.12.3 or higher is required and was not found (see the help page ?rmarkdown::pandoc_available).
    
    Execution halted
    
    [VSC-R] geneset_overlap.Rmd process exited with exit code 1
    [VSC-R] terminating R process
    

    Also important to note that this error doesn't pop up when pandoc is installed system-wide (say in /usr/local). On my other machine (M2 Mac), pandoc is installed system-wide and the "knit" button works in VS Code even though rmarkdown::pandoc_available() returns FALSE in the radian terminal.

    How is the "knit" button in VS code trying to locate the pandoc executable?

  20. ghar1821 commented on Jul 23, 2025

    @ghar1821

    Anyone managed to solve this? I've pretty much tried everything here with no avail. R terminal can find pandoc, but not radian.

    Trying to compile vignette using devtools::check() just failed:

    Pandoc is required to build R Markdown vignettes but not available. Please make sure it is installed.
    

    pandoc -v from terminal points to the right brew pandoc installation.

  21. ThomasSoeiro commented on Sep 27, 2026

    @ThomasSoeiro
    Collaborator

    I cannot reproduce with vscode-R 3.0.0

    and a system wide pandoc install (sudo dnf install pandoc on Fedora 41):

    $ which pandoc
    /usr/bin/pandoc

    and /usr/bin in the $PATH

    @eitsupi @Fred-Wu @grantmcdermott I think it can be closed or converted to a discussion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions