I had a simple shell script that ran the following:
Rscript -e 'rmarkdown::render("index.Rmd")'
After updating to macOS Catalina (10.15) I started getting the following error:
Error: pandoc version 1.12.3 or higher is required and was not found (see the help page ?rmarkdown::pandoc_available).
However, if I knit index.Rmd directly in RStudio, it works fine. And, when I check the pandoc version I get:
rmarkdown::pandoc_version()
[1] ‘2.3.1’
But, if I run the following in terminal I get:
Rscript -e 'rmarkdown::pandoc_version()'
NULL
Again, I can knit the file directly in RStudio, but I'm curious why my shell script stopped working and if anyone knows how to fix it.
I also posted this question in the RStudio Community here.
#mattwarkentin posted a solution that worked for me on the RStudio Community page.
Essentially, I just needed to install Pandoc system-wide using Homebrew:
brew install pandoc
Related
I am using Rstudio in windows 10. I am triying to create a pdf from a .tex file. However, when I compile the PDF, the following error appears:
Running pdflatex.exe on file_name.tex...failed Error running C:/Users/user_name/AppData/Local/Programs/MiKTeX/miktex/bin/x64/pdflatex.exe (exit code -1073740791)
I am using a native installation of R, Rstudio and MikTeX. Not an envioronment with anaconda or similar.
If you are using RStudio, have you tried tinytex instead of MikTeX? In the Tools Menu>Global Options>Sweave, tick "use tinytex for compiling .tex files". Then install tinytex package. After installing tinytex package, write in console "tinytex::install_tinytex()". This will install the latex compiler tinytex. Try compiling your tex file using it.
I think that issue has to do with missing packages. In fact, MiKTeX doesnt preinstall most of them. I recommend to compile with TinyTeX, because it shows where the compilation stops (as I said, due to a missing package typically required in some sty file). This way you can track which are the missing packages and install them on the MiKTeX Console one by one.
I posted about this issue in an open discussion on Github. Drop the link here in case you need more details.
I need to render forms with rmarkdown from a command line
this is where I am:
knit button in RStudio works fine
function rmarkdown::render(file.rmd) in a .r file works when run in Rstudio
Then I tried running this command in CMD
c:\Program Files\R\R-4.0.2\bin\Rscript.exe" -e "rmarkdown::render('C:/file.rmd')
and I get this error:
Error: pandoc version 1.12.3 or higher is required and was not found (see the help page ?rmarkdown::pandoc_available).
In RStudio I sent
> rmarkdown::pandoc_available()
[1] TRUE
> rmarkdown::pandoc_version()
[1] ‘2.7.3’
What am I missing here?
By the way, I'm on Win10.
Thanks.
There might be an issue wit h Pandoc version, obviously. But maybe some library requires that older pandoc version, and the issue comes from you using Rmarkdown from outside Rstudio.
This link has the answer
Go into Rstudio and type
Sys.getenv("RSTUDIO_PANDOC")
Now take the output from the command above and put it here
Sys.setenv(RSTUDIO_PANDOC="OUTPUT FROM ABOVE COMMAND")
I ran into this today. I installed R 3.4.3 along side R 3.4.1 . Using LyX/knitr under R 3.4.1 everything was fine. After adding R 3.4.3, changing the System/User/LyX PATH entries from 3.4.1 to 3.4.3, LyX launches Rscript, but it can no longer open the Rnw file in the TEMP folder. LyX freaks out and pops up an error message. My work around was to copy Rscript from R 3.4.1 and everything works again.
Did the command line parameters change from R-3.4.1 toR-3.4.3 ?
Everything seems fine for Rstudio and report compilation. Do the LyX Rscript command line parameters need to be changed for R-3.4.3 ? This occurred under Windows 10 on a X64 laptop and i386 tablet. It's consistent anyway!
Is there a fix for R-3.4.3 or LyX 2.2.3 ?
Updated info:
The LyX console reports the following:
18:10:32.825: Rscript --verbose --no-save --no-restore "C:/Users/dave/AppData/Local/LyX 2.2/Resources/scripts/lyxknitr.R" "C:/Users/dave/AppData/Local/Temp/lyx_tmpdir.WeWWkafx7016/lyx_tmpbuf0/""DES-knitr.Rnw" "C:/Users/dave/AppData/Local/Temp/lyx_tmpdir.WeWWkafx7016/lyx_tmpbuf0/""DES-knitr.tex" ISO-8859-15 "C:/Users/dave/LaTeX Work/Lyx Work/"
18:10:33.241: The filename, directory name, or volume label syntax is incorrect.
support/Systemcall.cpp (291): Systemcall: 'Rscript --verbose --no-save --no-restore "C:/Users/dave/AppData/Local/LyX 2.2/Resources/scripts/lyxknitr.R" "C:/Users/dave/AppData/Local/Temp/lyx_tmpdir.WeWWkafx7016/lyx_tmpbuf0/""DES-knitr.Rnw" "C:/Users/dave/AppData/Local/Temp/lyx_tmpdir.WeWWkafx7016/lyx_tmpbuf0/""DES-knitr.tex" ISO-8859-15 "C:/Users/dave/LaTeX Work/Lyx Work/"' finished with exit code 1
Error: Cannot convert file
----------------------------------------
An error occurred while running:
Rscript --verbose --no-save --no-restore $$s/scripts/lyxknitr.R
"C:/Users/dave/AppData/Local/Temp/lyx_tmpdir.WeWWkafx7016/lyx_tmpbuf0/""DES-kn…
18:10:41.526: Error while exporting format: PDF (pdflatex)
The tempfile exists and I can read it in Notepad++. Note that LyX works fine, R-3.4.3 works fine, but the LyX->Knitr->R->LaTeX-> PDF chain is broken in Rscript. For every installed R upgrade, I've changed the System/User/LyX PATH variables and everything has been fine with knitr until now. My next step is to completely uninstall LyX and R-3.4.3 and reinstall. I'm a little hesitant to proceed with that if I have a simple configuration change/error that may appear again in future upgrades to LyX (2.3) and R (3.4.3+).
I think the problem is that there are two different bin directories for R, one for x64, and one for i386.
So make sure LyX is configured to use the i386 path if you are on a 32 bit machine, e.g.
C:\R\bin\i386\
I can't knit to HTML or PDF anymore, although it used to work just fine. Here's the error I keep getting:
pandoc: out of memory (requested 1048576 bytes)
Error in strsplit(version_info, "\n")[[1]] : subscript out of bounds
Calls: <Anonymous> ... pandoc_available -> find_pandoc -> lapply -> FUN -> get_pandoc_version
In addition: Warning message:
running command ''/usr/lib/rstudio/bin/pandoc/pandoc' --version' had status 1
Execution halted
I used to have Rstudio 0.999.903, which I uninstalled, I then installed 1.0.44 version, reinstalled the knitr package through Rstudio, but I'm getting this error again.
I installed pandoc 1.18-1 from the git repository using the debian package installer, same problem again.
I later updated Rstudio to version 1.0.136 and pandoc to version 1.19.2.1 and no change.
I tried uninstalling R and re-installing a more recent version, again with no success.
The command-line works:
library(rmarkdown)
rmarkdown::render("test.Rmd", "html_document")
--
I'm using Debian (LMDE2).
Finally I got it!
It seems this bug was described 2 years ago by Arch users here.
It seems this bug was introduced for me with Rstudio version 0.98+ in a Debian system (I use LMDE Betsy).
The pandoc version installed along with Rstudio doesn't work, and when I installed pandoc manually Rstudio would stick to using its own broken version. Anyway the workaround is to remove the executable pandoc from Rstudio distro, and symlink another version of pandoc instead:
apt-get install pandoc
rm /usr/lib/rstudio/bin/pandoc/pandoc
ln -s /usr/bin/pandoc /usr/lib/rstudio/bin/pandoc/pandoc
rm /usr/lib/rstudio/bin/pandoc/pandoc-citeproc
ln -s /usr/bin/pandoc-citeproc /usr/lib/rstudio/bin/pandoc/pandoc-citeproc
I found this workaround here.
The repository has pandoc version 1.12, but more recent versions also work. I am now using pandoc 1.19.2.1 and Rstudio 1.0.136.
I am new to R and am trying to knit my R Markdown files into PDF format.
I continually get the error message:
pandoc: pdflatex not found. pdflatex is needed for pdf output.
Error: pandoc document conversion failed with error 41
Execution halted
No TeX installation detected (TeX is required to create PDF output). You should install a recommended TeX distribution for your platform:
Windows: MiKTeX (Complete) - http://miktex.org/2.9/setup
(NOTE: Be sure to download the Complete rather than Basic installation)
Mac OS X: TexLive 2013 (Full) - http://tug.org/mactex/
(NOTE: Download with Safari rather than Chrome strongly recommended)
Linux: Use system package manager
I have downloaded pandoc, and I have also downloaded TexLive and have installed them both onto my computer. For the life of me I cannot figure out why R wont recognize that Ive installed them, and knit into a PDF.
Please help!
For Mac OS X, if you have installed TexLive (I installed so through homebrew caskroom) you should have pdftex available via command line.
type 'which pdftex' to make sure something shows up. from there, i created a symbolic link into my $PATH, specifically into my /usr/local/bin (which is where all my homebrew stuff is stored) with:
ln -s /usr/texbin/pdftex /usr/local/bin/pdflatex
from there, using knitr in RStudio and R in general seemed to work and rendering R Markdown is definitely a really beautiful option (check some of the templates too like the Tufte one!)
I had the same problem, after downloading mactex through FireFox and installing the package.
I quit and restarted RStudio, and it worked (no changes at the terminal command line level).
The .pdf output is, however, a bit blurry at least on my first attempt.
I had a similar issue as I wasn't able to knit pdf file & solved it by installing & running tinitex packages using those commands in the console -- not the terminal
install.packages("tinytex")
tinytex::install_tinytex()