RStudio can't find LaTeX after Mavericks update - r

I have been using Sweave for quite sometime on my system using RStudio.
However, I recently upgraded my Mac OS from Lion to Mavericks.
This caused several issues:
First, RStudio was not able to locate the R library, and it just wont start. I reinstalled RStudio, but still got the same issue. So I reinstalled both R and RStudio, and then RStudio started to work.
And now, RStudio is still not able to locate TeX installation, and gives me the following warning:
"No TeX installation detected. Please install TeX before compiling."
This will probably get fixed by a reinstall, but I would prefer to avoid a fresh download of TeX (~2.3G).
Any ideas on how to resolve this?

RStudio expects pdflatex to be on the system path (i.e. entering Sys.which("pdflatex") at the R console should return the path to pdflatex).
You can fix the problem by getting pdflatex back on the system path:
Find the path where pdflatex is installed on your system--likely /usr/texbin, but use find /usr -name pdflatex if you need help.
Create a file called TeX in /etc/paths.d that contains this path.
For example:
$ sudo -s "echo /usr/texbin > /etc/paths.d/TeX"
You'll need to restart to apply the changes.

Related

RStudio error in windows: Running pdflatex.exe on file_name.tex.. (exit code -1073740791)

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.

Cannot open rstudio from command line though installation worked

I can't start rstudio from my linux terminal. It always shows me this message:
Unable to determine real path of R script /home/remi/anaconda3/bin/R (system error 2 (No such file or directory))
I have Kubuntu 18 and anaconda installed on it.
I had trouble with installing curl and other libraries that need curl.
Since it was maybe due to a problem of paths, I removed R and RStudio from my conda environment in order to work only on the R and RStudio installed in Kubuntu. Something must have gone wrong.
I have tried to remove and reinstall both R and RStudio but it didn't work.
Weirdly, I can launch RStudio from my application launcher and I was able to install all the libraries I needed.
I would like to be able to launch RStudio from the terminal without any problem.
Does someone know what the problem is ?
Thank you !

R cmd check Latex error: FATAL pdflatex - GUI framework cannot be initialized

I am checking my package and this is actually the last remaining problem. The pdf file cannot be compiled and the logfile tells me
2015-10-15 14:17:47,430+0200 INFO pdflatex - running 'initexmf --quiet --update-fndb' to refresh the file name database
2015-10-15 14:17:50,276+0200 FATAL pdflatex - GUI framework cannot be initialized.
2015-10-15 14:17:50,276+0200 FATAL pdflatex - Info:
2015-10-15 14:17:50,276+0200 FATAL pdflatex - Source: Libraries\MiKTeX\UI\Qt\mikuiqt.cpp
2015-10-15 14:17:50,276+0200 FATAL pdflatex - Line: 50
Any idea where the problem could be?
This is known problem wit MikTex 2.9 when pdflatex encounters error
GUI framework cannot be initialized.
(found on my Windows 7 system in the file ~\AppData\Local\MiKTeX\2.9\miktex\log)
So far, I can offer following sequence of actions to remedy this:
In Windows Command prompt go to MiKTeX bin folder (e.g. C:\Program Files (x86)\MiKTeX 2.9\miktex\bin) and run utility mo.exe;
In General tab change 'Install missing packages on-the-fly:' option to No (this will disable GUI and error above won't be happening again);
Run R CMD that calls latex converter again (in my case
R CMD Rd2pdf man/
again to see new errors;
This time miktex won't complaint about GUI - instead it will be missing packages with error like this
! LaTeX Error: File `inconsolata.sty' not found.
Start MiKTeX package manager (again from mo.exe Packages tab) and install missing package one at the time by repeating steps 3.-5.
This might be not most effective way of fixing this so I appreciate corrections or alternative solutions.
I had this same issue, but for the newest versions of Miktex, mo.exe does not exist, and is replaced by the Miktex console. If you open it, go into settings and change the package on-the-fly setting from "Ask Me" to "Always", then the packages will install. If you do "Never" instead, then you'll have to do the individual package installation described by #topchef.
I ran into this problem just... A very easy solution for me that allowed me not to renege on the install on the fly option is to install TexStudio, open your .tex file in there, and compile it: you will be able to install all your MikTex packages on the fly as desired and retain control over what gets installed.
I had the same problem compiling Knit to PDF of a R markdown file in R studio. Once I changed from "Ask me" to "Always" in the MikTex console setting (see the screenshot posted above [Cara Wogsland]) it compiled without errors.

R cmd check not locating texi2pdf on mac after R 3.1.3 upgrade

Does anyone have a link to clear instructions on how to install and configure the necessary latex packages to build R packages on a mac?
I have some scripts for building and checking R packages on a mac server. They seemed to work fine, but after upgrading to R 3.1.3, many of the packages started failing with
Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, :
Running 'texi2dvi' on 'networkVignette.tex' failed.
Messages:
sh: /usr/local/bin/texi2dvi: No such file or directory
Calls: <Anonymous> -> texi2pdf -> texi2dvi
Execution halted
I found a thread which seemed to suggest I need a more recent version texinfo (5.2) than what is installed by default. And apparently I've I've got the wrong version installed in the wrong location?
which texi2pdf
/sw/bin/texi2pdf
texi2pdf --version
texi2pdf (GNU Texinfo 5.1) 5234
(same version is reported when running system('texi2pdf --version') in R )
This thread gives a link to a texinfo 5.2 source collection:
http://r.789695.n4.nabble.com/R-CMD-build-looking-for-texi2dvi-in-the-wrong-place-R-devel-td4701706.html
But I'm not familiar with installing executable from a tar.gz file on a mac. The R mac help pages I found suggest installing MacTex, which I tried but that didn't seem to help.
** Update: ** additional discussion of related problems on R-SIG-mac mailing list:
https://groups.google.com/forum/#!topic/r-sig-mac/xjyuFdl5Ezk
Update:
Here is where I'm currently at:
I removed my /sw directory to uninstall fink and all of its packages (couldn't figure out how to upgrade it)
installed homebrew
brew install texinfo installs version 5.2 the package,
but generates the message This formula is keg-only, which means it was not symlinked into /usr/local and actually installs in in /usr/local/Cellar/texinfo/5.2/bin which means it is not on the path and R won't find it.
manually symlink each of the texi2pdf, texi2dvi , etc as vincent suggests (this is because R has the /usr/local/bin location as default in the tools::texi2dvi function?
edited the /etc/paths file on the system to add /usr/local/bin so that finds the brew installed 5.2 version before it finds it before the osx system supplied version 4.6 version. This may not be necessary because R has it hardcoded?
All of this gets rid of the "can't find texi* errors", and gives me a bunch of latex errors (which I don't see on unix and windows builds) so I'm still kind of stuck.
This seems very hackish, so there must be a cleaner way? But it sounds like stuff with tex and mac is very sketchy at the moment? https://tex.stackexchange.com/questions/208181/why-did-my-tex-related-gui-program-stop-working-in-mac-os-x-yosemite
This worked for me on Mavericks and on Yosemite:
ln -s /usr/bin/texi2dvi /usr/local/bin/texi2dvi
ln -s /usr/bin/texi2pdf /usr/local/bin/texi2pdf
On my Lion system both the command which texi2pdf at a Terminal/bash prompt and from a R.app GUI prompt tell me that I have that program in:
system("which texi2pdf")
#/opt/local/bin/texi2pdf
That is a location typical for MacPorts installation. I think the /usr/local/bin/ is what the binary R version "expects". I'm not really that UNIX savvy, but I think the you can modify the PATH environment variable so that R will be able to find your installation. (Whether it will be compatible I cannot say since so much detail is missing from your question.) My Tex installation is MacTex, which I got from https://www.tug.org/mactex/. I admit to having a cobbled-together system:
system("echo $PATH")
# /opt/local/bin:/opt/local/sbin:/sw/bin:/sw/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/texbin:/usr/X11/bin:/usr/X11R6/bin
That gets set at the beginning of an R session because this is the first line in my .Rprofile-(invisible)file:
Sys.setenv(PATH="/opt/local/bin:/opt/local/sbin:/sw/bin:/sw/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/texbin:/usr/X11/bin:/usr/X11R6/bin")
I think /sw/bin/ installations signify a fink install, which I have had very little success with. Simon Urbanek suggests not using any package installers, but then leaves the rest of us UNIX weenies very little in the way of worked examples of how to install that various external packages that underpin the many interesting and oh-so-useful R packages. So I feel your pain, but I'm not running for President.
So I suppose you could try this at your R console before again attempting one of the earlier unsuccessful installs:
Sys.setenv(PATH=paste( Sys.getenv()$PATH, # should be the character string of the $PATH
"/sw/bin/", sep=":")
)
Wish I could offer guarantees, but if it breaks the only guarantee is that you get to keep all the pieces.
I ran into a similar error message using Mavericks 10.9.5 (factory configured) and R 3.1.
It turns out that I didn't have pdfLaTex. I went to this page: http://tug.org/mactex/ and downloaded the MacTex installation package. It's big (>2GB) but after I installed it, my R package build problems went away.
Hope this might be helpful to anyone else who runs into this error message.

Knitting to PDF in R

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()

Resources