rstudio / tinytex

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

Installation failed: Can't exec "kpsewhich": No such file or directory at ./tlmgr line 65. #295

Closed Vouivre closed 3 years ago

Vouivre commented 3 years ago

Hello, I have installed TinyTeX in the past and it worked without problems. I have a linux system. If I try to install it, I get:

 wget -qO- "https://yihui.org/tinytex/install-bin-unix.sh" | sh
--2021-04-03 22:30:56--  https://yihui.org/tinytex/TinyTeX-1.tar.gz
Resolving yihui.org (yihui.org)... 76.76.21.21
Connecting to yihui.org (yihui.org)|76.76.21.21|:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://ci.appveyor.com/api/projects/yihui/tinytex/artifacts/TinyTeX-1.tar.gz?job=image%3A%20Ubuntu [following]
--2021-04-03 22:30:57--  https://ci.appveyor.com/api/projects/yihui/tinytex/artifacts/TinyTeX-1.tar.gz?job=image%3A%20Ubuntu
Resolving ci.appveyor.com (ci.appveyor.com)... 138.91.141.243
Connecting to ci.appveyor.com (ci.appveyor.com)|138.91.141.243|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://appveyorcidata.blob.core.windows.net/yihui-27038/tinytex/1-0-1492/c28cx0lr337fc3uv/TinyTeX-1.tar.gz?sv=2015-12-11&sr=c&sig=oAvzZXw%2BRbzvZVKjhfpQIXb%2BzTzbJDbjfrrbihlDZKQ%3D&st=2021-04-03T22%3A25%3A04Z&se=2021-04-03T22%3A31%3A04Z&sp=r [following]
--2021-04-03 22:30:57--  https://appveyorcidata.blob.core.windows.net/yihui-27038/tinytex/1-0-1492/c28cx0lr337fc3uv/TinyTeX-1.tar.gz?sv=2015-12-11&sr=c&sig=oAvzZXw%2BRbzvZVKjhfpQIXb%2BzTzbJDbjfrrbihlDZKQ%3D&st=2021-04-03T22%3A25%3A04Z&se=2021-04-03T22%3A31%3A04Z&sp=r
Resolving appveyorcidata.blob.core.windows.net (appveyorcidata.blob.core.windows.net)... 13.88.145.64
Connecting to appveyorcidata.blob.core.windows.net (appveyorcidata.blob.core.windows.net)|13.88.145.64|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 67132265 (64M) [application/octet-stream]
Saving to: 'TinyTeX.tar.gz'

     0K ........ ........ ........ ........ 49% 5.20M 6s
 32768K ........ ........ ........ ........ 99% 7.91M 0s
 65536K                                    100%  129K=10s

2021-04-03 22:31:09 (6.17 MB/s) - 'TinyTeX.tar.gz' saved [67132265/67132265]

Can't exec "kpsewhich": No such file or directory at ./tlmgr line 65.
Use of uninitialized value $Master in scalar chomp at ./tlmgr line 65.
Could not determine directory of tlmgr executable, maybe shared library woes?
Check for error messages above at ./tlmgr line 71.
BEGIN failed--compilation aborted at ./tlmgr line 80.
sh: true: unknown operand
Can't exec "kpsewhich": No such file or directory at ./tlmgr line 65.
Use of uninitialized value $Master in scalar chomp at ./tlmgr line 65.
Could not determine directory of tlmgr executable, maybe shared library woes?
Check for error messages above at ./tlmgr line 71.
BEGIN failed--compilation aborted at ./tlmgr line 80.

I don't remember exactly when I installed Tinytex the last time, but I'm almost sure it was before septembre 2020. I have read in between you are providing some binaries. On my Linux system I have:

Is the problem related with busybox or musl ?

If you need more information, just tell me which one. Thank you!

yihui commented 3 years ago

Sounds like the prebuilt TinyTeX binary package (provided since Sept 2020) doesn't work for your OS. You may need to install TinyTeX from source:

wget -qO- "https://yihui.org/tinytex/install-unx.sh" | sh

Could you tell me more about your OS?

uname -a
Vouivre commented 3 years ago

Thank you! I was able to install it without problems. My system:

 $ uname -a
Linux HOSTNAME 5.7.12 #7 SMP Wed Oct 21 07:21:26 UTC 2020 x86_64 GNU/Linux

My linux distribution is kisslinux which is based on musl. Some other distributions are also based on musl, but it's not the majority.

I let you close this issue, perhaps you will add a comment somewhere for such a case. It's possible that I missed it.

Great I can enjoy TinyTeX again!

yihui commented 3 years ago

This issue needs to be fixed, but I'm not familiar with kisslinux. In theory, I should exit here if I detect the OS is based on musl:

https://github.com/yihui/tinytex/blob/18cc7c50bc52ae0b09baefe8257f68b1196245d6/tools/install-bin-unix.sh#L14

but I don't know how to obtain the info about musl. It seems that it is not available in uname.

Vouivre commented 3 years ago

I don't understand very will this exit condition. If I'm right, it exits if $OSNAME is empty. Is that right ?

Perhaps there is a starting point here: https://stackoverflow.com/questions/58177815/how-to-actually-detect-musl-libc

On my system:

$   /lib/ld-musl-x86_64.so.1
musl libc (x86_64)
Version 1.2.2
Dynamic Program Loader
Usage: /lib/ld-musl-x86_64.so.1 [options] [--] pathname [args]

By chance, I have a chrooted partition on my system: kisslinux with glibc and not musl. Perhaps this could help:

cat /usr/lib/libc.so
/* GNU ld script
   Use the shared library, but some functions are only in
   the static library, so try that secondarily.  */
OUTPUT_FORMAT(elf64-x86-64)
GROUP ( /usr/lib/libc.so.6 /usr/lib/libc_nonshared.a  AS_NEEDED ( /usr/lib/ld-linux-x86-64.so.2 ) )

In some distributions, perhaps you can have this information in uname -a, honestly I don't know. It should be tested in voidlinux or alpine for example.

If you want to, I can ask the best way to know if musl is used instead of glibc, perhaps there is something better than /lib/ld-musl-x86_64.so.1.

If I ask, what about opening an issue on github, so you could be involved in the discussion? The other possibility would be on reddit, but I don't know if you have an account. Github makes more sense for me.

EDIT: Ok, I get it. In the exit condition with $OSNAME you want to know if it's a linux/unix system. Right ? But your intention is not to differentiate a glibc from a musl based system.

yihui commented 3 years ago

Basically I want to make sure the x86_64-linux binary that I built under Ubuntu won't be installed on other Linux platforms. Currently I'm only testing if uname returns Linux: https://github.com/yihui/tinytex/blob/18cc7c50bc52ae0b09baefe8257f68b1196245d6/tools/install-bin-unix.sh#L41

That test is not sufficient in your case.

The current platform can be queried via:

$ tlmgr print-platform
universal-darwin

All supported platforms are:

$ tlmgr platform list
Available platforms:
    aarch64-linux
    amd64-freebsd
    amd64-netbsd
    armhf-linux
    i386-cygwin
    i386-freebsd
    i386-linux
    i386-netbsd
    i386-solaris
(i) universal-darwin
    win32
    x86_64-cygwin
    x86_64-darwinlegacy
    x86_64-linux
    x86_64-linuxmusl
    x86_64-solaris
Already installed platforms are marked with (i)

I'm wondering how I can make sure I won't install a TinyTeX binary that was built on one platform into another platform. This might be too much to ask you, though.

Vouivre commented 3 years ago

That's right, I had no idea there was so much platform. For sure I know almost all platform but until know in this issue I thought there was only musl and glibc. I'm not a dev, I do my best, but perhaps I can help you. After seaching I found some interesting information. From this thread, I know bash set the variable $OSTYPE. On my system I get:

 $ echo $OSTYPE
linux-musl

My shell is zsh, unfortunately on sh this variable is empty. I find it pretty fun, found an issue from the creator of kiss linux. With:

bash -c "echo $OSTYPE"

you can get the information you want probably. On my system:

$  bash -c "echo $OSTYPE"
linux-musl

In this case, even if bash is not the default shell, this command can be executed. Even if bash is not the default shell in kiss linux, I think most of the users have it installed. In other distributions it's installed for all users. But I'm not sure it's the same for bsd for example.

Perhaps the best is here: there is a script which is executed with sh: config.guess

On my system:

$ config.guess
x86_64-pc-linux-musl

It should be tested, but I expect it gives you exactly what you want to. You could test it on your system. It seems to be maintained, the last modifications was in 2021. In this case you only have to call it from your script.

yihui commented 3 years ago

Thanks! That's extremely helpful! I read the source code of the TeX Live installer for a while and discovered that it actually uses the config.guess (the Perl subroutine platform() defined in tlpkg/TeXLive/TLUtils.pm).

Before I try the config.guess solution, I wonder what uname -o returns on your platform (this command might be more portable than the env var OSTYPE). Oh actually from your uname -a output, I guess uname -o should return GNU/Linux. I'll use OSTYPE.

yihui commented 3 years ago

It should be fixed now (i.e., the original command wget -qO- "https://yihui.org/tinytex/install-bin-unix.sh" | sh should work now). Thanks for the report!

Vouivre commented 3 years ago

I have tested and it works. Thank you for the fix! :+1: