emacs 的 shell-command 执行结果为何与终端不同?

先说一下动机, 我头脑一热安装了 mactex 2023, 安装以后慢了 8 倍, 我想要重新用回 texlive 2018. 通过修改 PATH, 终端我可以用 2018 的 xelatex 正常编译文件了. 但是 org mode 预览还是出了错. 我调试了一下, 发现

/usr/local/texlive/2018/bin/x86_64-darwin/xelatex --shell-escape -interaction nonstopmode -output-directory=/Users/quebec/Downloads/ ../../Downloads/tmp.tex

的结果会有这样几行:

kpathsea: Running mktexfmt xelatex.fmt
mktexfmt: mktexfmt is using the following fmtutil.cnf files (in precedence order):
mktexfmt:   /usr/local/texlive/2018/texmf-dist/web2c/fmtutil.cnf
mktexfmt: mktexfmt is using the following fmtutil.cnf file for writing changes:
mktexfmt:   /Users/quebec/Library/texlive/2023/texmf-config/web2c/fmtutil.cnf
mktexfmt [INFO]: writing formats under /Users/quebec/Library/texlive/2023/texmf-var/web2c
mktexfmt [INFO]: --- remaking xelatex with xetex
mktexfmt: running `xetex -ini   -jobname=xelatex -progname=xelatex -etex xelatex.ini' ...
This is XeTeX, Version 3.141592653-2.6-0.999995 (TeX Live 2023) (INITEX)
 restricted \write18 enabled.
entering extended mode

我不知道它为什么会用 2023 的文件, 然后转到用 2023 的 xetex 中.

我在终端执行同样的命令:

/usr/local/texlive/2018/bin/x86_64-darwin/xelatex --shell-escape -interaction nonstopmode -output-directory=/Users/quebec/Downloads/ ../../Downloads/tmp.tex

能正常生成 pdf, 没有任何问题. 一模一样的命令, 区别只是 shell-command 与终端运行的区别, 结果怎么会不一样?

好像文件用到了相对路径,要不看看 shell-command 时,当前目录是啥,路径有没有问题?

中间经历了种种混乱以后, 我又做了一系列操作以后, 直接说结果, exec-path 与 shell PATH 不一致, 执行了 exec-path-from-shell-initialize 后问题解决. 但我中间还做了很多操作(与 tex 有关的操作), 我不确定这是不是唯一原因.

这是Emacs 在 macOS 上的老问题了。真希望 Emacs 能直接在 master 分支解决这个问题。