rstudio / tinytex

A lightweight, cross-platform, portable, and easy-to-maintain LaTeX distribution based on TeX Live
https://yihui.org/tinytex/
Other
987 stars 116 forks source link

Portability seems broken #133

Open micheljung opened 5 years ago

micheljung commented 5 years ago

Hi,

The documentation claims that TinyTeX is portable, but that doesn't seem to be the case.

On Linux, it can be reproduced like this.

1. Install TinyTeX"

wget -qO- "https://yihui.name/gh/tinytex/tools/install-unx.sh" | sh

2. Find all occurrences of the user's home directory

grep -R --exclude="*.log" ${HOME} .TinyTeX/

In a portable installation, you would expect that there are no hardcoded paths. Yet, there are:

.TinyTeX/texmf-dist/web2c/updmap.cfg:# Generated by /home/michel/.TinyTeX/bin/x86_64-linux/tlmgr on Fri Jul 12 07:41:22 2019
.TinyTeX/texmf-dist/web2c/fmtutil.cnf:# Generated by /home/michel/.TinyTeX/bin/x86_64-linux/tlmgr on Fri Jul 12 07:41:22 2019
.TinyTeX/tlpkg/texlive.profile:tlpdbopt_sys_bin /home/michel/bin
.TinyTeX/tlpkg/texlive.tlpdb:depend opt_sys_bin:/home/michel/bin
.TinyTeX/tlpkg/tlpobj/00texlive.installation.tlpobj:depend opt_sys_bin:/home/michel/bin
.TinyTeX/texmf-var/fonts/map/pdftex/updmap/pdftex.map:% /home/michel/.TinyTeX/texmf-var/fonts/map/pdftex/updmap/pdftex_dl14.map:
.TinyTeX/texmf-var/fonts/map/pdftex/updmap/pdftex.map:% /home/michel/.TinyTeX/texmf-var/web2c/updmap.log
.TinyTeX/texmf-var/fonts/map/pdftex/updmap/pdftex_dl14.map:% /home/michel/.TinyTeX/texmf-var/fonts/map/pdftex/updmap/pdftex_dl14.map:
.TinyTeX/texmf-var/fonts/map/pdftex/updmap/pdftex_dl14.map:% /home/michel/.TinyTeX/texmf-var/web2c/updmap.log
.TinyTeX/texmf-var/fonts/map/pdftex/updmap/pdftex_ndl14.map:% /home/michel/.TinyTeX/texmf-var/fonts/map/pdftex/updmap/pdftex_ndl14.map:
.TinyTeX/texmf-var/fonts/map/pdftex/updmap/pdftex_ndl14.map:% /home/michel/.TinyTeX/texmf-var/web2c/updmap.log
.TinyTeX/texmf-var/fonts/map/dvips/updmap/psfonts.map:% /home/michel/.TinyTeX/texmf-var/fonts/map/dvips/updmap/psfonts_t1.map:
.TinyTeX/texmf-var/fonts/map/dvips/updmap/psfonts.map:% /home/michel/.TinyTeX/texmf-var/web2c/updmap.log
.TinyTeX/texmf-var/fonts/map/dvips/updmap/builtin35.map:% /home/michel/.TinyTeX/texmf-var/fonts/map/dvips/updmap/builtin35.map:
.TinyTeX/texmf-var/fonts/map/dvips/updmap/builtin35.map:% /home/michel/.TinyTeX/texmf-var/web2c/updmap.log
.TinyTeX/texmf-var/fonts/map/dvips/updmap/psfonts_pk.map:% /home/michel/.TinyTeX/texmf-var/fonts/map/dvips/updmap/psfonts_pk.map:
.TinyTeX/texmf-var/fonts/map/dvips/updmap/psfonts_pk.map:% /home/michel/.TinyTeX/texmf-var/web2c/updmap.log
.TinyTeX/texmf-var/fonts/map/dvips/updmap/ps2pk.map:% /home/michel/.TinyTeX/texmf-var/fonts/map/dvips/updmap/ps2pk.map:
.TinyTeX/texmf-var/fonts/map/dvips/updmap/ps2pk.map:% /home/michel/.TinyTeX/texmf-var/web2c/updmap.log
.TinyTeX/texmf-var/fonts/map/dvips/updmap/psfonts_t1.map:% /home/michel/.TinyTeX/texmf-var/fonts/map/dvips/updmap/psfonts_t1.map:
.TinyTeX/texmf-var/fonts/map/dvips/updmap/psfonts_t1.map:% /home/michel/.TinyTeX/texmf-var/web2c/updmap.log
.TinyTeX/texmf-var/fonts/map/dvips/updmap/download35.map:% /home/michel/.TinyTeX/texmf-var/fonts/map/dvips/updmap/download35.map:
.TinyTeX/texmf-var/fonts/map/dvips/updmap/download35.map:% /home/michel/.TinyTeX/texmf-var/web2c/updmap.log
.TinyTeX/texmf-var/fonts/map/dvipdfmx/updmap/kanjix.map:% /home/michel/.TinyTeX/texmf-var/fonts/map/dvipdfmx/updmap/kanjix.map:
.TinyTeX/texmf-var/fonts/map/dvipdfmx/updmap/kanjix.map:% /home/michel/.TinyTeX/texmf-var/web2c/updmap.log
Binary file .TinyTeX/texmf-var/web2c/metafont/mf.base matches
Binary file .TinyTeX/texmf-var/web2c/tex/tex.fmt matches

Of which these are probably relevant:

.TinyTeX/tlpkg/texlive.profile:tlpdbopt_sys_bin /home/michel/bin
.TinyTeX/tlpkg/texlive.tlpdb:depend opt_sys_bin:/home/michel/bin
.TinyTeX/tlpkg/tlpobj/00texlive.installation.tlpobj:depend opt_sys_bin:/home/michel/bin
Binary file .TinyTeX/texmf-var/web2c/metafont/mf.base matches
Binary file .TinyTeX/texmf-var/web2c/tex/tex.fmt matches

3. Pack .TinyTeX

tar czf /tmp/tinytex.tar.gz .TinyTeX

4. As another user, unpack .TinyTeX

tar xzf /tmp/tinytex.tar.gz

5. Execute tlmgr path add

.TinyTeX/bin/x86_64-linux/tlmgr path add

Which results in:

Can't locate TeXLive/TLConfig.pm in @INC (you may need to install the TeXLive::TLConfig module) (@INC contains: /.TinyTeX/texmf-dist/scripts/texlive /.TinyTeX/tlpkg /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.26.1 /usr/local/share/perl/5.26.1 /usr/lib/x86_64-linux-gnu/perl5/5.26 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.26 /usr/share/perl/5.26 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at .TinyTeX/bin/x86_64-linux/tlmgr line 100.
BEGIN failed--compilation aborted at .TinyTeX/bin/x86_64-linux/tlmgr line 100.

6. Test TinyTeX

mkdir -p rpackages
echo ".libPaths('~/rpackages')" > .Rprofile
R --silent -e 'install.packages("tinytex")'
R --silent -e 'tinytex::tinytex_root()'

Results in:

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

Session Info

> xfun::session_info(tinytex)
Error in xfun::session_info(tinytex) : object 'tinytex' not found
Execution halted

By filing an issue to this repo, I promise that

I understand that my issue may be closed if I don't fulfill my promises.

yihui commented 5 years ago

You are correct that the default installation on Linux is not strictly portable. That is due to a trade-off: I want the default installation to just work. If a true portable TinyTeX is desired, you have to know more about TeX Live. First, use the method in FAQ 5 to install TinyTeX: https://yihui.name/tinytex/faq/ That is, use the flags --admin --no-path, which means it will not create $HOME/bin or add symlinks there. As a result, you will have to either add $HOME/.TinyTeX/bin/x86_64-linux to your PATH variable, or call those TeX Live executables with their full paths. When you move the TinyTeX installation directory, you'll have to repeat this step (change PATH or use the new full paths).

micheljung commented 5 years ago

Hi and thank you for your response. I installed it using --admin --no-path and added $HOME/.TinyTeX/bin/x86_64-linux to PATH.

Now I get:

> tinytex::tinytex_root()
Error in tinytex::tinytex_root() :
  Cannot figure out the root directory of TeX Live from /home/michel/.TinyTeX/bin/x86_64-linux/tlmgr (not a symlink on unix)
Execution halted

I understand that tinytex_root explicitly requires tlmgr to be a symlink, which now it isn't.

Basically, I need an offline installation since I'm behind a corparate proxy, like #121. Since I'm on Linux I can't use tinytex:::install_windows_zip().

I looked into tinytex:::install_prebuilt and saw it executes download-travis-linux.sh so I followed that but apparently, the prebuilt Linux package has /home/travis hardcoded so it doesn't work either:

$cd ~/.TinyTeX/bin/*/
$./tlmgr path add
mkdir(/home/travis/bin/) failed for tree /home/travis/bin: Permission denied
add of symlinks had 1 error(s), see messages above.
tlmgr: An error has occurred. See above messages. Exiting.

So again, it doesn't seem to be as portable as advertised :-) What can you recommend?

Update

When I replace depend opt_sys_bin:/home/travis/bin in .TinyTeX/tlpkg/texlive.tlpdb, it seems to work:

sed -i -e "s;depend opt_sys_bin:.*;depend opt_sys_bin:${HOME}/bin;g" .TinyTeX/tlpkg/texlive.tlpdb
pushd .TinyTeX/bin/x86_64-linux/
./tlmgr path add
popd
> tinytex::tinytex_root()
[1] "/home/michel/.TinyTeX"

But this shouldn't be necessary, should it?

Also, it only works with the prebuilt TinyTeX. With the one built with --admin --no-path I get:

> tinytex::tinytex_root()
[1] "/home/michel"
yihui commented 5 years ago

tinytex::tinytex_root should definitely not require tlmgr to be a symlink. That is a bug. You are welcome to submit a pull request if you can figure out the fix: https://github.com/yihui/tinytex/blob/07cea7ffb0e04b1f78a7b20192b279a7f35a3793/R/install.R#L258-L263

Thanks!

simaoafonso-pwt commented 4 years ago

https://tug.org/texlive/doc/install-tl.html#PROFILES

It seems the install-tl option on the profile should be instopt_portable, or am I reading this wrong?

yihui commented 4 years ago

@simaoafonso-pwt I think they recently changed the names of the options. I just updated them in the profile file. Thanks!

simaoafonso-pwt commented 4 years ago

I checked and it seems compatibility was maintained, since I don't get docs nor source code.

In fact, I tried the changes you did and there was an error about missing options, sorry about that. :cry:

Unknown key(s) in profile /tmp/tmp.VYVhbNUozy/tinytex.profile: tlpdbopt_option_doc tlpdbopt_option_src tlpdbopt_option_autobackup
Stopping here.

Revert it quick, before anyone notices!


No matter what, I get the path on the following files:

$ grep -R "$PWD" --exclude='*.log' -l .
./tlpkg/texlive.profile
./texmf-var/fonts/conf/texlive-fontconfig.conf
./texmf-var/fonts/map/pdftex/updmap/pdftex.map
./texmf-var/fonts/map/pdftex/updmap/pdftex_dl14.map
./texmf-var/fonts/map/pdftex/updmap/pdftex_ndl14.map
./texmf-var/fonts/map/dvipdfmx/updmap/kanjix.map
./texmf-var/fonts/map/dvips/updmap/psfonts.map
./texmf-var/fonts/map/dvips/updmap/builtin35.map
./texmf-var/fonts/map/dvips/updmap/psfonts_pk.map
./texmf-var/fonts/map/dvips/updmap/psfonts_t1.map
./texmf-var/fonts/map/dvips/updmap/download35.map
./texmf-var/fonts/map/dvips/updmap/ps2pk.map
grep: ./bin/x86_64-linux/man: No such file or directory
./texmf-dist/web2c/fmtutil.cnf

For now, I think it's fair enough the environment is not portable (I mean I won't chase this further myself). This is a similar behaviour to Python's venv.

I think a better approach is trying to share the remote cache between users, or just run a local TUG mirror with a limited number of packages, and add that as the first repository.

yihui commented 4 years ago

Okay. Thank you very much for testing! Just reverted the commit.