rstudio / tinytex

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

TinyTeX's `TEXMFHOME` configuration not deleted #433

Open auralioth opened 10 months ago

auralioth commented 10 months ago

Thanks! I just removed TinyTeX's TEXMFHOME configuration, so that it will just use TeX Live's default setting. This will be reflected in the next build of TinyTeX (which will hopefully be ready in about an hour). Or you can delete TEXMFHOME manually:

tlmgr conf texmf --delete TEXMFHOME

Then verify by

kpsewhich -var-value TEXMFHOME

Oddly, it returns ~/texmf instead of ~/Library/texmf on my macOS. I'm not sure if this is a bug, but you can definitely change it:

tlmgr conf texmf TEXMFHOME ~/Library/texmf

Originally posted by @yihui in https://github.com/rstudio/tinytex/issues/377#issuecomment-1176255177

屏幕截图 2024-01-10 120951

As shown in the screenshot, after I installed tinytex with scoop and after each update, the default location of TEXMFHOME became $TEXMFLOCAL instead of ~/texmf, which is the default location of texlive on Windows systems. Could you please make some modifications in install-windows.bat?

cderv commented 10 months ago

Could you please make some modifications in install-windows.bat

Are you using the bat script or scoop install tinytex from the cderv/r-bucket ?

The scoop installation is just downloading the release bundle from https://github.com/rstudio/tinytex-releases/releases/tag/v2024.01

I don't think we do anything specific regarding configuration at https://github.com/cderv/r-bucket/blob/master/bucket/tinytex.json

Which is the version of TinyTeX you have install in scoop ?

I need to check what is the windows default..

cderv commented 10 months ago

I don't use scoop install but install using the R package tinytex and I still get this

> kpsewhich -var-value TEXMFHOME
C:/Users/chris/AppData/Roaming/TinyTeX/texmf-local

I got this as configuration:

> bat c:/Users/chris/AppData/Roaming/TinyTeX/texmf.cnf
───────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: c:/Users/chris/AppData/Roaming/TinyTeX/texmf.cnf
───────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ % (Public domain.)
   2   │ % This texmf.cnf file should contain only your personal changes from the
   3   │ % original texmf.cnf (for example, as chosen in the installer).
   4   │ %
   5   │ % That is, if you need to make changes to texmf.cnf, put your custom
   6   │ % settings in this file, which is .../texlive/YYYY/texmf.cnf, rather than
   7   │ % the distributed file (which is .../texlive/YYYY/texmf-dist/web2c/texmf.cnf).
   8   │ % And include *only* your changed values, not a copy of the whole thing!
   9   │ %
  10   │ TEXMFLOCAL = $SELFAUTOPARENT/texmf-local
  11   │ OSFONTDIR = $SystemRoot/fonts//;$LOCALAPPDATA/Microsoft/Windows/Fonts//
  12   │ ASYMPTOTE_HOME = $TEXMFCONFIG/asymptote
  13   │ TEXMFHOME = $TEXMFLOCAL
  14   │ TEXMFVAR = $TEXMFSYSVAR
  15   │ TEXMFCONFIG = $TEXMFSYSCONFIG
  16   │
  17   │ % Prefer external Perl for third-party TeXLive Perl scripts
  18   │ % Was set to 1 if at install time a sufficiently recent Perl was detected.
  19   │ TEXLIVE_WINDOWS_TRY_EXTERNAL_PERL = 0
  20   │ max_print_line = 10000
  21   │ TEXMFAUXTREES = C:/PROGRA~1/R/R-42~1.0/share/texmf,
cderv commented 10 months ago

Fresh installation after uninstalling and reinstalling give me the same configuration

TEXMFHOME = $TEXMFLOCAL
auralioth commented 10 months ago

Are you using the bat script or scoop install tinytex from the cderv/r-bucket ?

I am using scoop install

Which is the version of TinyTeX you have install in scoop ?

v2024.01

Fresh installation after uninstalling and reinstalling give me the same configuration

TEXMFHOME = $TEXMFLOCAL

Yes, it is.

If installing it manually according to the texlive official website, TEXMFHOME should be the default, which is ~/texmf. So where might tinytex change when packaging?

cderv commented 10 months ago

So where might tinytex change when packaging?

That is the question :) Looking into it

cderv commented 10 months ago

@yihui some questions about how it is supposed to work

I think the issue relies in texlive.profile which should be used of the configuration as we do https://github.com/rstudio/tinytex/blob/main/tools/install-windows.bat#L34

We correctly use the profile for installation in CI (https://github.com/rstudio/tinytex/actions/runs/7469845614/job/20327605730#step:8:61)

Automated TeX Live installation using profile: ../tinytex.profile

So it seems the values are correctly passed and should be read so no override of default...

It seems TinyTeX is not overriding this value 🤔 I am trying to understand how texlive installation sets it.

Related topic while reading source code:

https://github.com/rstudio/tinytex/blob/48d08431ec7ca34b4e1ddb783f757d506038d5f4/tools/install-windows.bat#L26-L27

Is this suppose to write the content of $TEXMFSYSCONFIG into the file or add those line into

TEXMFCONFIG $TEXMFSYSCONFIG >> tinytex.profile 
TEXMFVAR $TEXMFSYSVAR >> tinytex.profile

into the file ?

Because if the latter, it needs quotes

-echo TEXMFCONFIG $TEXMFSYSCONFIG>> tinytex.profile 
+echo 'TEXMFCONFIG $TEXMFSYSCONFIG' >> tinytex.profile 
- echo TEXMFVAR $TEXMFSYSVAR>> tinytex.profile
+echo 'TEXMFVAR $TEXMFSYSVAR' >> tinytex.profile
cderv commented 10 months ago

OK so I think I found it.

The content we see if from installer https://github.com/TeX-Live/installer/blob/fa5010f553f47ff07d8730efe8de944071dd8e2a/install-tl#L1548-L1585

Specifically this :

  if ($vars{'instopt_portable'}) {
    print TMF "TEXMFHOME = \$TEXMFLOCAL\n";
    print TMF "TEXMFVAR = \$TEXMFSYSVAR\n";
    print TMF "TEXMFCONFIG = \$TEXMFSYSCONFIG\n";
  }

And this is activated because do set portable in the profile we pass https://github.com/rstudio/tinytex/blob/48d08431ec7ca34b4e1ddb783f757d506038d5f4/tools/tinytex.profile#L13

So I guess

TEXMFHOME = $TEXMFLOCAL

is the default for portable installation. From man page:

-portable Install for portable use, e.g., on a USB stick. See the instopt_portable description below for details.

instopt_portable (default 0) Install for portable use, e.g., on a USB stick, without touching the host system. Specifically, this forces the user directories > TEXMFHOME, TEXMFCONFIG, TEXMFVAR to be identical to the system directories TEXMFLOCAL, TEXMFSYSCONFIG, > TEXMFSYSVAR, respectively (regardless of other options and environment variable.) In addition, on Windows, it disables the desktop integration, path adjustment, and file associations actions usually performed.

@yihui I don't know if you knew that. This probably means that https://github.com/rstudio/tinytex/commit/170d9145496f356a29a398a24f9fd984bb4372e2 is not exactly doing what was expected. Or that previous value set in profile was better maybe... 🤔

yihui commented 10 months ago

So I guess

TEXMFHOME = $TEXMFLOCAL

is the default for portable installation.

@cderv Thanks for the diagnosis! I didn't know that (or perhaps I knew once but forgot later).

@auryouth I think the solution is tlmgr conf texmf --delete TEXMFHOME after installing TinyTeX, but the question is who should run this command, i.e., whether we (TinyTeX maintainers) or users should delete TeX Live's default TEXMFHOME configuration. I don't have an opinion and am fine with either way.

cderv commented 10 months ago

, whether we (TinyTeX maintainers) or users should delete TeX Live's default TEXMFHOME configuration.

This can be done with tinytex using tinytex::tlmgr_conf(c("texmf", "--delete", "TEXMFHOME")) so a user could run it easily I think. If we were to do it, I think we should make it an option argument in the installation. Not sure which would be the name, or maybe it should be a way to customize TEXMFHOME at installation.

I think we should keep TeX Live default for portable as a default for tinytex but definitely allow helpers on how to change.

auralioth commented 10 months ago

tlmgr conf texmf --delete TEXMFHOME

I also think this can be included as an option in the scoop app manifest or bat script.