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.codefrom 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/binOther Commands as
ls, which are also in/usr/bindirectory do work from the vscode internal terminal (aslsaswell/usr/bin/ls).properties of pdflatex:
$ ls -l /usr/bin/pdflatex lrwxrwxrwx 1 root root 6 Feb 17 2021 /usr/bin/pdflatex -> pdftexor
$file /usr/bin/pdflatex /usr/bin/pdflatex: symbolic link to pdftexand pdftex (same behavior as pdflatex):
$ ls -l /usr/bin/pdftex -rwxr-xr-x 1 root root 2115048 Mar 13 2021 /usr/bin/pdftexor
$ 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, strippedthe 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/bindoes not exist. (/appdoes not exist)I tried to change the
PATHin 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.shis my wrapper script):declare -p LD_LIBRARY_PATH declare -p LD_PRELOADThe outputs are as follows: native Terminal:
./makeTex.sh: line 4: declare: LD_LIBRARY_PATH: not found ./makeTex.sh: line 5: declare: LD_PRELOAD: not foundvscode Terminal:
declare -x LD_LIBRARY_PATH="/app/lib" ./makeTex.sh: line 5: declare: LD_PRELOAD: not foundThe 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 $PATHin the integrated terminal? – schrodingerscatcuriosity Sep 21 '21 at 12:21lsor/usr/bin/ls, does that work? Finally, what is the output ofls -l usr/bin/pdflatex? – terdon Sep 21 '21 at 13:49PATHlikeexport PATH=/usr/binis wrong, append to it./usr/binshould 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 thePATHin VSCode: Does/app/binexist? Did you configure the path inside VSCode? Please show the output offile /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 invokeenvordeclare -p. Does the output mentionLD_LIBRARY_PATHorLD_PRELOAD? – Kamil Maciorowski Sep 21 '21 at 21:50/appwhich is often used with containers. – polemon Sep 24 '21 at 05:52