4

I'm having the same issue as this question:

When I open any .Rnw file, R Studio says that I have no TeX Distribution installed: I'm using Ubuntu 14.04 w/ Gnome and TeXLive 2014.

I include the line PATH=/usr/local/texlive/2014/bin:${PATH} in the Renviron.site file, which now looks like:

##                      Emacs please make this -*- R -*-
## empty Renviron.site for R on Debian
##
## Copyright (C) 2008 Dirk Eddelbuettel and GPL'ed
##
## see help(Startup) for documentation on ~/.Renviron and Renviron.site

# ## Example ~/.Renviron on Unix
# R_LIBS=~/R/library
# PAGER=/usr/local/bin/less

# ## Example .Renviron on Windows
# R_LIBS=C:/R/library
# MY_TCLTK="c:/Program Files/Tcl/bin"

# ## Example of setting R_DEFAULT_PACKAGES (from R CMD check)
# R_DEFAULT_PACKAGES='utils,grDevices,graphics,stats'
# # this loads the packages in the order given, so they appear on
# # the search path in reverse order.

PATH=/usr/local/texlive/2014/bin:${PATH}

However the problem persists. How can I fix this and run Sweave or knitR?

Community
  • 1
  • 1
Bernardo
  • 426
  • 3
  • 16

2 Answers2

2

If anyone faces the same problem, I opened R Studio and checked the pdflatex installation with

> Sys.which("pdflatex")
pdflatex 
  "" 

Which show that it is in fact empty, so I run the command Sys.getenv("PATH")to check the current PATH:

Sys.getenv("PATH")
[1]   "/usr/local/texlive/2014/bin:/usr/local/texlive/2014/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"

To add my pdflatex Path, I had to find the pdflatex file on my texlive directory, which was /usr/local/texlive/2014/bin/x86_64-linux, then I added this to my current Path:

> Sys.setenv(PATH=paste(Sys.getenv("PATH"),"/usr/local/texlive/2014/bin/x86_64-linux",sep=":"))

And now it works perfectly

EDIT: the solution above works only for the open session and is only temporary, you have to run the code everytime you open a new session. I'm still trying to find a permanent solution

Bernardo
  • 426
  • 3
  • 16
2

see this page: Customizing Startup, modify this file /usr/lib/R/etc/Rprofile.site, and put your code in this file. It looks like a permanent solution maybe.

===

i saw this file /etc/environment is the same as the output of Sys.getenv("PATH"), so i think that sys.getenv("PATH") reads file /etc/environment.

Therefore the better way is to modify this file /etc/environment adding this code :/usr/local/texlive/2017/bin/x86_64-linux​.

after i did it, i tried source /etc/envronment and restarted Rstudio, but it didn't work.

Finally it makes sense after i restarted my ubuntu system. ^_^

I hope my poor English expression is clear enough.

Community
  • 1
  • 1