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

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

Related

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

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.

"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.

Rcpp error through RExcel

I have a problem in using Rcpp from Rexcel.
(especially, sourceCpp() function)
I'm running a 64-bit Windows 10 platform.
I installed R ver 3.3.1 and RExcel.
I also installed Rtools by Rtools34.exe.
I can use RExcel properly if I don't use sourceCpp().
Hoewver, when I use sourceCpp() function, I have an error.
From Rexcel, I execute the command
library(Rcpp)
and this step, there is no error.
Next, I put the following command
sourceCpp("C:/Users/ChrisCCCCC/Desktop/ChrisCCCCC/program/samplecode.cpp")
and Run code.Then, the error message
Error in command:
sourceCpp("C:/Users/ChrisCCCCC/Desktop/ChrisCCCCC/program/samplecode.cpp")
'C:/Program' not found
attr(,class)
[1] try-error
Is anyone else know the reason of this error?
Of course I set the path for Rtools.
and I can run the code
sourceCpp("C:/Users/ChrisCCCCC/Desktop/ChrisCCCCC/program/samplecode.cpp")
with no error from normal RGui and RStudio.
Why sourceCpp() causes an error through RExcel while there is no error through normal RGui?
Can anyone help me, please?

Affdex 'opencv-webcam-demo' Crashes in Ubuntu 16.04

I made a program that was based off of the demo program on the affdex git page found here. It is the demo called 'opencv-webcam-demo'. I was running Ubuntu 14.04 at the time and it worked fine. I then upgraded to Ubuntu 16.04 and now the demo (even without my changes) does not run properly. I tried to install the latest versions of opencv and boost and confirmed that they were installed correctly but I still get the same issue.
Here is the output when I run the program in Ubuntu 16.04:
ethan#ethan-HP-Pavilion-dv6-Notebook-PC:~/leepsProgram/build/opencv-webcam-demo$ ./opencv-webcam-demo --help
Hit ESCAPE key to exit app..
Encountered an exception std::exception*** Error in `./opencv-webcam-demo': free(): invalid pointer: 0x0000000001c71ca8 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x77725)[0x7f0ce2798725]
/lib/x86_64-linux-gnu/libc.so.6(+0x7ff4a)[0x7f0ce27a0f4a]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7f0ce27a4abc]
./opencv-webcam-demo(_ZN5boost10filesystem4pathD1Ev+0x18)[0x469c86]
/lib/x86_64-linux-gnu/libc.so.6(__cxa_finalize+0x9a)[0x7f0ce275b35a]
/home/ethan/libraries/affdex-sdk/lib/libaffdex-native.so(+0x5273a3)[0x7f0ce642a3a3]
There was also a Memory Map so if that helps then let me know and I can paste that in here too.
So far I have tried to figure out what part of the code works and what part does not work and found that if you remove boost from the program it will reach up until the point were Affdex has to specify a path to the data folder, at which point it throws an Affdex Exception saying that the data path must be non-null. However it should not be null because I set it at the start.
affdex::path DATA_FOLDER = "<path to data folder>";
...
frameDetector->setClassifierPath(DATA_FOLDER);
Still, removing boost is not ideal since it is already coded for me. But if I have to remove boost then I must solve this issue as well.
Libraries and their versions / OS version:
Boost 1.59.0
OpenCV 3.1.0
Affdex 3.1-396
Ubuntu 16.04
Are these libraries compatible with Ubuntu 16.04?
Thanks for any help. It is greatly appreciated.
I think the problem is that you are mixing libraries with compiled with incompatible versions of libstdc++ .. What is the compiler version you are using?
The current version of the linux SDK was compiled with GCC 4.8
UPDATED: I have solved this problem by updating SDK version to the newest version (https://download.affectiva.com/linux/gcc-5.4/affdex-cpp-sdk-4.0-75-ubuntu-xenial-xerus-x86_64bit.tar.gz).
The tutorial provided the old version:
wget https://download.affectiva.com/linux/affdex-cpp-sdk-3.2-20-ubuntu-xenial-xerus-64bit.tar.gz
I have similar problem, with similar error log. Please consider to upgrade or find a better way to the C++ samples version. Many people try to use the same C++ code for testing. I wasted a lot of time to figure out why?
Debugging starts
Hit ESCAPE key to exit app..
Initializing Affdex FrameDetector
*** Error in `/home/aiq/Desktop/aiq_workspace/cpp-sdk-samples/build/opencv-webcam-demo/opencv-webcam-demo': munmap_chunk(): invalid pointer: 0x0000000000856e10 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7ffff582c7e5]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x1a8)[0x7ffff5839698]
/home/aiq/Desktop/aiq_workspace/cpp-sdk-samples/build/opencv-webcam-demo/opencv-webcam-demo(_ZN5boost10filesystem4pathD1Ev+0x18)[0x467948]
/home/aiq/Desktop/aiq_workspace/affdex-sdk/lib/libaffdex-native.so(_ZN6affdex12DetectorBase17setClassifierPathERKSs+0xc6)[0x7ffff6f5061a]
/home/aiq/Desktop/aiq_workspace/affdex-sdk/lib/libaffdex-native.so(_ZN6affdex8Detector17setClassifierPathERKSs+0x2f)[0x7ffff6f4abb1]
/home/aiq/Desktop/aiq_workspace/cpp-sdk-samples/build/opencv-webcam-demo/opencv-webcam-demo(main+0xaed)[0x466110]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7ffff57d5830]
/home/aiq/Desktop/aiq_workspace/cpp-sdk-samples/build/opencv-webcam-demo/opencv-webcam-demo(_start+0x29)[0x465209]
Please look into the issue. Comments not taking long answer, so I post as an answer here.

Error in compiling when installing Stan for R and when using Rcpp

I need to install Rstan for a data analysis class. The instructions are posted here http://code.google.com/p/stan/wiki/RStanGettingStarted. I'm running Mac OS 10.5.8 and R 2.15.1 GUI 1.52 Leopard build 32-bit (6188). I just installed Xcode version 3.1.4, the Xcode c++ compiler that is compatible with leopard (I had to get a mac developer account to do this).
Per the Stan installation instruction, I entered the following code to see if my compiler was working:
library(inline)
library(Rcpp)
src <- '
std::vector<std::string> s;
s.push_back("hello");
s.push_back("world");
return Rcpp::wrap(s);
'
hellofun <- cxxfunction(body = src, includes = '', plugin = 'Rcpp', verbose = FALSE)
cat(hellofun(), '\n')
It returns the following error:
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created!
Library/Frameworks/R.framework/Versions/2.15/Resources/library/
Rcpp/include/Rcpp/internal/export.h: In function ‘void
Rcpp::internal::export_range__dispatch(SEXPREC*, InputIterator,
Rcpp::traits::r_type_primitive_tag)’:
/Library/Frameworks/R.framework/Versions/2.15/Resources/
library/Rcpp/include/Rcpp/internal/export.h:56: internal
compiler error: Bus error
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://developer.apple.com/bugreporter> for
instructions.
make: *** [file795214e66510.o] Error 1
In addition: Warning message:
running command '/Library/Frameworks/R.framework/Resources/bin/
R CMD SHLIB file795214e66510.cpp 2>
file795214e66510.cpp.err.txt' had status 1
When I try to install stan:
install.packages('rstan', type = 'source') ]
I get this warning:
Warning message:
In install.packages("rstan", type = "source") :
installation of package ‘rstan’ had non-zero exit status
I have no idea how C++ works. All of my coding experience is in R and has not before required compiling into C++. I've been trying really hard to figure out what's wrong for the last 4 hours or so, googling these error messages over and over without much luck. Any help would be greatly appreciated and would also help about 10 other students in my class who are having identical or analogous problems. Thank you very, very much.
This looks to me like an issue with the installation of your C++ compiler or with your installation of the Rcpp package, rather than an issue with the rstan package. However, if g++ is causing an intractable problem for you, an alternative is the clang compiler, which should work with Rcpp and rstan if you create $HOME/.R/Makevars with these two lines
CC=clang
CXX=clang++
As mentioned in another answer, the first step is to get Rcpp working on your Mac (i.e,. at least pass the hello world example).
A similar issue for Rcpp previously:
https://stat.ethz.ch/pipermail/r-sig-mac/2010-July/007574.html
In addition, from this webpage http://useyourloaf.com/blog/2011/03/21/compiler-options-in-xcode-gcc-or-llvm.html, it seems that gcc 4.2 and 4.0 are both in Xcode 3.14 (not sure as it does not say it's 3.14). So try to make sure gcc 4.2.1 is used by R is important. Executing the following in a terminal will show what is the current version of gcc.
$ g++ -v