What are some possible causes, that a command could not be found in Linux? Other than it is not in the PATH
?
Some background info:
When trying to execute pdflatex from vscode, I got some troubles, that vscode was not able to find pdflatex. Probably because the PATH
is not set correctly. Since I was not able to fix the problem right away, I tried to work around this problem by executing a shell script, which then calls pdflatex:
#!/bin/bash
export PATH=/usr/bin
pdflatex $@
or
#!/bin/bash
/usr/bin/pdflatex $@
In both cases, the script works as expected when executed over the normal terminal. But when executed in the vscode intern terminal it says
pdflatex: command not found
As far as I know, the only way that a command can not be found, is if it is not in a directory included by the PATH
. Or when the absolute path is wrong. But this seems not to be the case here.
So what other factors are used to determine, how a command is searched for?
Additional Infos (as requestet)
OS: POP OS 21.04
from vscode terminal:
$ echo $PATH /app/bin:/usr/bin:/home/flo/.var/app/com.visualstudio.code
from a native terminal:
$ echo $PATH /opt/anaconda3/bin:/opt/anaconda3/condabin:/home/flo/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin
Other Commands as
ls
, which are also in/usr/bin
directory do work from the vscode internal terminal (asls
aswell/usr/bin/ls
).properties of pdflatex:
$ ls -l /usr/bin/pdflatex lrwxrwxrwx 1 root root 6 Feb 17 2021 /usr/bin/pdflatex -> pdftex
or
$file /usr/bin/pdflatex /usr/bin/pdflatex: symbolic link to pdftex
and pdftex (same behavior as pdflatex):
$ ls -l /usr/bin/pdftex -rwxr-xr-x 1 root root 2115048 Mar 13 2021 /usr/bin/pdftex
or
$ file /usr/bin/pdftex /usr/bin/pdftex: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=88c89d7d883163b4544f9461668b73383e1ca04e, for GNU/Linux 3.2.0, stripped
the following script gives also the same output:
#!/bin/bash pdflatex $@
The original (copied, without any edits) script is as follow:
#!/bin/bash
#export PATH=/usr/bin #printenv PATH pdflatex $@ #/usr/bin/pdflatex $@
To test the other scripts, I changed the comments and deleted the irrelevant lines in the post here.
/app/bin
does not exist. (/app
does not exist)I tried to change the
PATH
in vscode (inside the LaTeX Workshop extensions) since this is most likely the cause for my problem in the first place. However, I could neither fix the problem nor confirm in any way, that my configs (for the LaTeX Workshop extension) had any effect at all.when adding the following lines to the script (
makeTex.sh
is my wrapper script):declare -p LD_LIBRARY_PATH declare -p LD_PRELOAD
The outputs are as follows: native Terminal:
./makeTex.sh: line 4: declare: LD_LIBRARY_PATH: not found ./makeTex.sh: line 5: declare: LD_PRELOAD: not found
vscode Terminal:
declare -x LD_LIBRARY_PATH="/app/lib" ./makeTex.sh: line 5: declare: LD_PRELOAD: not found
The problem occured by using vscode 1.57.1 (installed via flatpak). Other versions of vscode (at least vscodium 1.60.1) do not show the same behavior.
echo $PATH
in the integrated terminal? – schrodingerscatcuriosity Sep 21 '21 at 12:21ls
or/usr/bin/ls
, does that work? Finally, what is the output ofls -l usr/bin/pdflatex
? – terdon Sep 21 '21 at 13:49PATH
likeexport PATH=/usr/bin
is wrong, append to it./usr/bin
should already be there. What is the exact error message when you run the second script (withpdflatex $@``) from VSCode? I would expect a different error message. Did you copy&paste the code from the scripts? In case you re-typed it you might have fixed an error from your actual script. Regarding the
PATHin VSCode: Does
/app/binexist? Did you configure the path inside VSCode? Please show the output of
file /usr/bin/pdflatex`. If it is a script (text), show its contents. (or the first lines if it's long) – Bodo Sep 21 '21 at 14:28$@
is not what you want when writing a wrapper script; you want"$@"
. This is irrelevant to the issue though. (2) In the script invokeenv
ordeclare -p
. Does the output mentionLD_LIBRARY_PATH
orLD_PRELOAD
? – Kamil Maciorowski Sep 21 '21 at 21:50/app
which is often used with containers. – polemon Sep 24 '21 at 05:52