tinytex:::is_tinytex() returns true, but I still cannot knit to a PDF from rmarkdown - r-markdown

When I knit to pdf, I get a pop up that says "The code execution cannot proceed because luatex.dll was not found. Reinstalling the program may fix this problem." I click OK, then I get this output:
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020/W32TeX)
(preloaded format=pdflatex) restricted \write18 enabled. Running the
command
C:\Users\Ryan.M.Allen\AppData\Roaming\TinyTeX\bin\win32\fmtutil-user.exe
I can't find the format file `pdflatex.fmt'!
kpathsea: Running mktexfmt pdflatex.fmt
The command name is
C:\Users\Ryan.M.Allen\AppData\Roaming\TinyTeX\bin\win32\mktexfmt I was
unable to find any missing LaTeX packages from the error log
BA_LunchLearn.log. ! Running the command
C:\Users\Ryan.M.Allen\AppData\Roaming\TinyTeX\bin\win32\fmtutil-user.exe
! kpathsea: Running mktexfmt pdflatex.fmt
! The command name is
C:\Users\Ryan.M.Allen\AppData\Roaming\TinyTeX\bin\win32\mktexfmt
Error: LaTeX failed to compile BA_LunchLearn.tex. See
https://yihui.org/tinytex/r/#debugging for debugging tips. See
BA_LunchLearn.log for more info. In addition: Warning message: package
'corrplot' was built under R version 3.6.3 Execution halted
I have tried uninstalling tinytex and reinstalling it and then restarting Rstudio each time. I also get the output of TRUE when I run the command tinytex:::is_tinytex(). So I think it is on my machine but the pdf knit does not work.

Related

unable to knit pdf on M2 Mac: pandoc error Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/pandoc: Bad CPU type in executable

I get this error
sh: /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/pandoc: Bad CPU type in executable
Error in strsplit(info, "\n")[[1]] : subscript out of bounds
In addition: Warning message:
In system(paste(shQuote(path), "--version"), intern = TRUE) :
running command ''/Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/pandoc' --version' had status 126
MAC OS: 13.1
Macbook Air M2
Rstudio: 2022.12.0+353
Can someone please help. Thanks!
As suggested by #guna, I followed the GitHub link to find the solution. What I needed to do was run the following code in the Terminal:
/usr/sbin/softwareupdate --install-rosetta --agree-to-license
After this, the knitting started working fine again. No RStudio or R restart needed.
Ok, looks like Ventura upgrade removed Rosetta 2
Fix; install Rosetta 2
More here;
https://github.com/rstudio/rstudio/issues/12512

Error when compile RMarkdown pdf file with package `vtable`

I encounter errors when running the following simple code in RMarkdown.
---
title: "debugging"
author: ""
date: "11/12/2021"
output: pdf_document
---
```{r}
library(vtable)
st(iris,out="kable")
```
I am using the latest version of tinytex and all R packages.
The error message looks like:
! Misplaced \noalign. \bottomrule ->\noalign
{\ifnum 0=`}\fi #aboverulesep =\aboverulesep \global... l.168 \bottomrule
Error: LaTeX failed to compile debug.tex. See
https://yihui.org/tinytex/r/#debugging for debugging tips. See
debug.log for more info. Execution halted
or
I was unable to find any missing LaTeX packages from the error log
manual.log. ! Misplaced \noalign. \addlinespace ->\noalign
{\ifnum 0=`}\fi #ifnextchar [{#addspace }{#addsp... l.190 \addlinespace
Error: LaTeX failed to compile manual.tex. See
https://yihui.org/tinytex/r/#debugging for debugging tips. See
manual.log for more info. In addition:
Warning messages:
1: package'vtable' was built under R version 3.6.2
2: package 'kableExtra' was built under R version 3.6.2 Execution halted
in my origin rmd file with similar code (different data frame).

I can't knit my rmarkdown files - pandoc error

My university provided laptop was recently replaced and now when I try to knit my Rmd files if get the following error:
pandoc.exe: \\: openBinaryFile: invalid argument (Invalid argument)
Error: pandoc document conversion failed with error 1
Execution halted
These files used to knit perfectly on my old laptop and all of the code blocks within the file still run without errors.
The pandoc_available() function returns TRUE
The answers to similar questions that I have searched suggest it is something to do with the file paths but I am not familiar enough with this to make sense of what I should do. I tried mapping a network drive (Z:) to the folder where the Rmd file is stored and then changing the working directory in RStudio to that drive but it hasn't helped (and now I don't know how to change it back to ~ or what that referred to in the first place)
I have also tried downloading the latest version of Pandoc and a search on Windows Explorer shows that has installed in my user directory but I also have a version in C:\Program Files\RStudio\bin. That has also not helped.
I'm not sure if this is relevant but here is the information on the R version that I am running:
R version 4.0.3 (2020-10-10) -- "Bunny-Wunnies Freak Out"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)
Can you tell me what other information is required to diagnose the problem and I will edit to include.
I am sorry this question is so poorly specified and would appreciate any help to improve it.
**** UPDATE ****
I have found that if I
(i) specify that I want a .md file in the YAML header,
(ii) create an .md file by knitting the markdown file,
(iii) copy that .md file manually to the Pandoc directory
(iv) run pandoc.exe -s -o test.knit.md test.html from the MSDOS command prompt within the Pandoc directory,
then I can create the html output file.
However, changing the working directory for RStudio to the Pandoc directory and running
x <- rmarkdown::render("test.Rmd", run_pandoc = FALSE, clean = FALSE)
knit_meta <- attr(x, "knit_meta")
rmarkdown::render( input = 'test.knit.md' , knit_meta = knit_meta )
as per https://stackoverflow.com/questions/38908766/how-to-generate-an-md-file-from-a-rmarkdown-file-containing-an-htmlwidget gives the same error as shown in my original post.
Does this prompt any thoughts that might lead to a solution to my problem?
The university IT people were able to solve my problem by uninstalling R and RStudio from the network drive and installing it on the C: drive and I am now able to knit successfully.

Errors I face when I knit a RMarkdown file

When I knit my RMarkdown file, I face this error:
Sorry, but C:\Users\Narges.BT\AppData\Local\Programs\MiKTeX\miktex\bin\x64\pdflatex.exe did not succeed.
! The log file hopefully contains the information to get MiKTeX going again:
! C:\Users\Narges.BT\AppData\Local\MiKTeX\miktex\log\pdflatex.log
! pdflatex: major issue: So far, you have not checked for MiKTeX updates.
Error: LaTeX failed to compile trial.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See trial.log for more info.
Execution halted
I installed and updated MicTex console properly and have tried all the solutions that have been provided earlier.
Does anyone have any idea of what actions should I take?

"Abort Trap: 6" when attempting OpenCV video capture on macOS Mojave

I've tried on both Python on C++, and every time I call cap.open(0), I get an Abort Trap: 6 error. I haven't been able to find any solutions to this via Google, and have tried reinstalling OpenCV several times now. Any suggestions?
iTerm might be messing things up for you. It worked for me when I used the normal terminal.
Most likely your mac blocks the webcam access.
Check
System Pref -> Security & Privacy -> Privacy -> Camera.
If the app that you try to use is not listed there, opencv produce "Abort trap: 6"
In VSCode:
Do cmd+shift+p
Enter "shell command: Install code in PATH"
Close VS Code
Use sudo code to open VS Code
It will give a warning not to run as a root user
Ignore the warning and run the file, and you will not get the "Abort trap: 6" error anymore.
install code in vsstudio code and then open terminal and type code, it will open visual studio code and it will have all the permisions.