How do I to specify TinyTex root for users?

I was able to successfully install TinyTex on my RStudio Server using the tinytex::install_tinytex() function.

I confirmed it installed in my root directory using the Linux terminal:

> tinytex::tinytex_root()
[1] "/root/.TinyTeX"

However, when I execute the code in the R console, it does not return a path:

> tinytex::tinytex_root()
[1] ""

My hunch is that I need to specify the path to "/root/.TinyTeX" for each user. How can I do that? I cannot find documentation in the tinytex package that achieves this without executing a reinstall.

Hi,

To clarify, are you trying to make an installation for all users on a same server ?

So it looks like we're halfway there.

I am able to knit a markdown document as a PDF, but there are numerous errors in the markdown terminal. I would like to get these resolved so that my outputs are cleaner and future issues will be easier to debug.

I followed executed the following code to uninstall my previous TinyTeX:

sudo /usr/local/bin/R

tinytex::uninstall_tinytex()

With TinyTeX uninstalled from /root/.TinyTeX, I executed Yihui's code listed at on point 5, which you can see below.

wget -qO- "https://yihui.org/tinytex/install-unx.sh" \
  | sh -s - --admin --no-path

sudo ~/.TinyTeX/bin/*/tlmgr path add

After that, I knitted the R markdown file. Below is the output, with numerous errors. For some reason, there are multiple attempts to install different packages or libraries. Are these R packages or more variations of TinyTeX? How can I install them for all users so that I can avoid these messages?

Edit: I believe the issue has to do with the following note the Maintenance section of TinyTex's documentation: This section is only for those who are not R Markdown users — everything is automatic for R Markdown users, and you don’t need to manually search for or install missing LaTeX packages. Are the errors below LaTeX packages that are being attempted to install because of using R Markdown? Would executing tlmgr install multirow , tlmgr install mktexlsr, etc. adress this issue? Will I likely need to execute these with sudo?

|......................................................................| 100%
  ordinary text without R code

output file: File_Name.knit.md

/usr/lib/rstudio-server/bin/pandoc/pandoc +RTS -K512m -RTS File_Name.utf8.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output File_Name.tex --self-contained --highlight-style tango --pdf-engine pdflatex --variable graphics --lua-filter /opt/R/3.6.3/lib/R/library/rmarkdown/rmd/lua/pagebreak.lua --lua-filter /opt/R/3.6.3/lib/R/library/rmarkdown/rmd/lua/latex-div.lua --include-in-header /tmp/RtmpnnJ9q4/rmarkdown-str720128520173.html 
tlmgr: package repository https://ctan.math.illinois.edu/systems/texlive/tlnet (verified)
[1/1, ??:??/??:??] install: multirow [3k]
running mktexlsr ...
done running mktexlsr.
tlmgr: package log updated: /home/user/.TinyTeX/texmf-var/web2c/tlmgr.log
TLUtils::add_remove_symlinks: add of symlinks had 1 error(s), see messages above.
add_link_dir_dir: destination /usr/local/bin not writable, no links from /home/user/.TinyTeX/bin/x86_64-linux.
tlmgr: An error has occurred. See above messages. Exiting.
tlmgr: package repository http://ctan.math.utah.edu/ctan/tex-archive/systems/texlive/tlnet (verified)
[1/1, ??:??/??:??] install: wrapfig [10k]
running mktexlsr ...
done running mktexlsr.
tlmgr: package log updated: /home/user/.TinyTeX/texmf-var/web2c/tlmgr.log
TLUtils::add_remove_symlinks: add of symlinks had 1 error(s), see messages above.
add_link_dir_dir: destination /usr/local/bin not writable, no links from /home/user/.TinyTeX/bin/x86_64-linux.
tlmgr: An error has occurred. See above messages. Exiting.
tlmgr: package repository https://mirrors.rit.edu/CTAN/systems/texlive/tlnet (verified)
[1/1, ??:??/??:??] install: colortbl [4k]
running mktexlsr ...
done running mktexlsr.
tlmgr: package log updated: /home/user/.TinyTeX/texmf-var/web2c/tlmgr.log
TLUtils::add_remove_symlinks: add of symlinks had 1 error(s), see messages above.
add_link_dir_dir: destination /usr/local/bin not writable, no links from /home/user/.TinyTeX/bin/x86_64-linux.
tlmgr: An error has occurred. See above messages. Exiting.
tlmgr: package repository https://ctan.math.illinois.edu/systems/texlive/tlnet (verified)
[1/1, ??:??/??:??] install: pdflscape [3k]
running mktexlsr ...
done running mktexlsr.
tlmgr: package log updated: /home/user/.TinyTeX/texmf-var/web2c/tlmgr.log
TLUtils::add_remove_symlinks: add of symlinks had 1 error(s), see messages above.
add_link_dir_dir: destination /usr/local/bin not writable, no links from /home/user/.TinyTeX/bin/x86_64-linux.
tlmgr: An error has occurred. See above messages. Exiting.
tlmgr: package repository http://ctan.mirrors.hoobly.com/systems/texlive/tlnet (verified)
[1/2, ??:??/??:??] install: tabu [24k]
[2/2, 00:11/00:12] install: varwidth [5k]
running mktexlsr ...
done running mktexlsr.
tlmgr: package log updated: /home/user/.TinyTeX/texmf-var/web2c/tlmgr.log
TLUtils::add_remove_symlinks: add of symlinks had 1 error(s), see messages above.
add_link_dir_dir: destination /usr/local/bin not writable, no links from /home/user/.TinyTeX/bin/x86_64-linux.
tlmgr: An error has occurred. See above messages. Exiting.
tlmgr: package repository https://mirrors.rit.edu/CTAN/systems/texlive/tlnet (verified)
[1/1, ??:??/??:??] install: threeparttable [6k]
running mktexlsr ...
done running mktexlsr.
tlmgr: package log updated: /home/user/.TinyTeX/texmf-var/web2c/tlmgr.log
TLUtils::add_remove_symlinks: add of symlinks had 1 error(s), see messages above.
add_link_dir_dir: destination /usr/local/bin not writable, no links from /home/user/.TinyTeX/bin/x86_64-linux.
tlmgr: An error has occurred. See above messages. Exiting.
tlmgr: package repository https://mirrors.concertpass.com/tex-archive/systems/texlive/tlnet (verified)
[1/1, ??:??/??:??] install: threeparttablex [3k]
running mktexlsr ...
done running mktexlsr.
tlmgr: package log updated: /home/user/.TinyTeX/texmf-var/web2c/tlmgr.log
TLUtils::add_remove_symlinks: add of symlinks had 1 error(s), see messages above.
add_link_dir_dir: destination /usr/local/bin not writable, no links from /home/user/.TinyTeX/bin/x86_64-linux.
tlmgr: An error has occurred. See above messages. Exiting.
tlmgr: package repository http://ctan.mirrors.hoobly.com/systems/texlive/tlnet (verified)
[1/2, ??:??/??:??] install: environ [2k]
[2/2, 00:05/00:07] install: trimspaces [1k]
running mktexlsr ...
done running mktexlsr.
tlmgr: package log updated: /home/user/.TinyTeX/texmf-var/web2c/tlmgr.log
TLUtils::add_remove_symlinks: add of symlinks had 1 error(s), see messages above.
add_link_dir_dir: destination /usr/local/bin not writable, no links from /home/user/.TinyTeX/bin/x86_64-linux.
tlmgr: An error has occurred. See above messages. Exiting.
tlmgr: package repository https://mirrors.rit.edu/CTAN/systems/texlive/tlnet (verified)
[1/1, ??:??/??:??] install: ulem [7k]
running mktexlsr ...
done running mktexlsr.
tlmgr: package log updated: /home/user/.TinyTeX/texmf-var/web2c/tlmgr.log
TLUtils::add_remove_symlinks: add of symlinks had 1 error(s), see messages above.
add_link_dir_dir: destination /usr/local/bin not writable, no links from /home/user/.TinyTeX/bin/x86_64-linux.
tlmgr: An error has occurred. See above messages. Exiting.
tlmgr: package repository http://ctan.mirrors.hoobly.com/systems/texlive/tlnet (verified)
[1/1, ??:??/??:??] install: makecell [5k]
running mktexlsr ...
done running mktexlsr.
tlmgr: package log updated: /home/user/.TinyTeX/texmf-var/web2c/tlmgr.log
TLUtils::add_remove_symlinks: add of symlinks had 1 error(s), see messages above.
add_link_dir_dir: destination /usr/local/bin not writable, no links from /home/user/.TinyTeX/bin/x86_64-linux.
tlmgr: An error has occurred. See above messages. Exiting.

Output created: File_Name.pdf

Do you know a bit how LaTeX works ?

TeX document will often use some packages (\usepackage) - you need those packages to be installed or allow users to install them.

tinytex R package will install any missing package to render a Rmd file so that you don't have to know yourself what is needed. However, this require write access.

Most of the time, TinyTeX distribution is installed by user so there is no issue. However, when you install with root as an admin you need

  • Either to pre-install a set of packages, and if missing for some users, install them as an admin, using command line or R
  • Either configure your server so that the users will have the correct access to install the package. That is point 6 of the mentioned FAQ.

The permission stuff is mentioned in end of point 5 in the FAQ too.

This is not something easy to have all that setup.

Maybe the easiest thing to do is to preinstall some package to be used. I configured once a server for R users to be used with Latex, and I installed the full TeX Live distribution, included all packages (several Gb) so that users won't have to install anything.

TinyTeX offer some release with a set of package, the most used for an R usage:

Maybe this could help you.

I also opened an issue to update the FAQ with this:

Thank you for opening that issue. I'll keep an eye on that.

I know very little about how Linux or LaTeX works. Most of my experience comes from using RStudio Desktop on Windows, where most things "just worked" because I was a local user.

Regarding the options you mentioned, I believe Option A fits the best. Since I have already installed TinyTeX, and it appears that there are some LaTeX packages R Markdown is attempting to install, would the code sudo tlmgr install package_name achieve Option A?

Yes I believe this command would work to install the missing packages.
Within R it would be tinytex::tlmgr_install() with an R session opened by your root user where you installed the distribution.
For example :

sudo tlmgr install wrapfig  multirow

or

tinytex::tlmgr_install(c("wrapfig", "multirow")

Thank you for your help, @cderv. With your notes and a conversation with my team, we were able to create a central location for users to access TinyTeX. Below is our solution, feel free to comment if there is a glaring issue:

# Install Perl Digest MD5 -------------------------------------------------

# The `tinytex` package needs this to install.

sudo yum install perl-Digest-MD5
# Install `tinytex` Package -----------------------------------------------

# The package contains useful functions for managing and debugging TinyTeX.

# install.packages("tinytex", repos = "https://cloud.r-project.org/")
# Install TinyTeX As Admin ------------------------------------------------

# According to #5 on the FAQ of TinyTeX (https://yihui.org/tinytex/faq/),

# a different set of commands must be used to make TinyTeX available to all

# users.  Below are the steps.

# Install the TinyTeX library to the admin user's account.

wget -qO- "https://yihui.org/tinytex/install-unx.sh" \
| sh -s - --admin --no-path

# Install the TinyTeX packages mentioned in the `R Markdown` terminal's output.

sudo ~/.TinyTeX/tlmgr install package1 package2

# Centralize TinyTeX

sudo cp ~/.TinyTeX /data/TinyTeX/.TinyTeX

# Once `.TinyTeX` is in the desired folder, its path can be added to the users' .bashrc file.

sudo /data/TinyTeX/.TinyTeX/bin/*/tlmgr path add
1 Like

Sounds good ! Glad it is working !

If you have any feedbacks regarding the current TinyTeX documentation, like the FAQ, please feel free to share so we can improve!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.

To install it globally as an admin, you can follow the advice on

point 5 and others related from there.

I think that would be the best way to do it as it is the advice of the author.

Yes. I would like to install TinyTex once and that would enable anyone to use its features.

The steps I took in the Linux terminal are detailed below:

sudo yum install perl-Digest-MD5

sudo /usr/local/bin/R

# The two lines below are interpreted as R commands

install.packages("tinytex", repos = "https://cloud.r-project.org/")

tinytex::install_tinytex()