Re: Running tlmgr/tlshell with sudo

Bruno Voisin via tex-live <[email protected]>
Newsgroups gmane.comp.tex.live
Message-ID <[email protected]>
Hi Karl,

(Top-posting because all your quoted message below is relevant)

I wasn't clear, sorry.

Things are exactly as you describe: with or without -H, "sudo tlshell" always creates root-owned files.

My problem is exactly the one that Norbert dealt with in updmap-sys and fmtutil-sys: I was expecting tlshell (or tlmgr, I don't know which of the two matters here)  to behave the same, namely not to need -H, so that "sudo tlshell" would behave the same as "sudo -H tlshell". It doesn't.

As a consequence, "sudo tlshell" created a root-owned TEXMFCONFIG/tlmgr/config = ~/Library/texlive/2026/texmf-config/tlmgr/config.

Then, when I ran texdoc later, it tried to create a user-owned TEXMFVAR/texdoc/cache-tlpdb.lua = ~/Library/texlive/2026/texmf-var/texdoc/cache-tlpdb.lua, and couldn't, because "sudo tlshell" had created ~/Library/texlive/2026 and made it root-owned.

I thought all the TeX Live scripts written by Norbert included the same kludge as updmap-sys and fmtutil-sys. Knowing now that they don't, I'll try to remember to use sudo -H.

Thanks for the clarification,

Bruno


PS In the early years of TeX on Mac OS X, about two decades ago, Herb Schulz spent innumerable hours (I'm not exaggerating) helping people fix their TeX setup, which had been compromised by an incorrect mix of sudo (-H), updmap(-sys) and fmtutil(-sys), resulting in root-owned files in user directories, or the inadvertent creation of user-specific setups which kept precedence afterwards. 

When Norbert rewrote updmap and fmtutil in Perl and added this kludge, this saved the day for everyone.



> On 12 Feb 2026, at 00:36, Karl Berry <[email protected]> wrote:
> 
> Bruno, I'm somewhat baffled. If you run any command as sudo, anything
> that's created will have root ownership. Using -H or not is immaterial.
> I don't believe our scripts ever try to chown anything, and I don't
> think they should.
> 
> You-all have said that it's standard practice to use sudo to install
> things on the Mac. So I do not know how you ever end up with a TL tree
> that is not entirely owned by root -- does the MacTeX installer chown
> everything after? Or maybe it is owned by root, and that's ok? But your
> msg implies otherwise.
> 
> --
> 
> Norbert did insert code into fmtutil and updmap to try to avoid the need
> for -H, but this is a different question from the ownership of what is
> created. Here are his comments (it's the same for fmtutil):
> 
>  # $HOME and sudo and updmap-sys horror
>  #   some instances of sudo do not reset $HOME to the home of root
>  #   as an effect of "sudo updmap" creates root owned files in the home 
>  #   of a normal user, and "sudo updmap-sys" uses map files and updmap.cfg
>  #   files from the directory of a normal user, but creating files
>  #   in TEXMFSYSCONFIG. This is *all* wrong.
>  #   we check: if we are running as UID 0 (root) on Unix and the
>  #   ENV{HOME} is NOT the same as the one of root, then give a warning
>  #   and reset it to the real home dir of root.
>  sub reset_root_home { ... }
> 
> As far as I can tell, no other scripts (not tlmgr, not install-tl, not
> tlshell, not anything) have this kludge. Maybe I'm wrong.
> 
> 
> So, overall, I'm not sure what to do about this. --thanks, karl.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.