When I run this in a zsh shell, everything is fine:
mvim --servername VIM --remote-silent test.tex
The mvim GUI opens and the clientserver is opened correctly.
However, when I run the following python script:
import subprocess
subprocess.call([
"gvim",
"--servername VIM --remote-silent",
"test.tex"])
The mvim GUI opens but it hasn't opened the file, and it hasn't created the clientserver. Even if we change mvim to /opt/homebrew/bin/gvim, nothing improves.
Moreover, if I delete the clientserver line and run the following:
import subprocess
subprocess.call([
"gvim",
"test.tex"])
This time the mvim GUI is opened and the file is opened correctly.
Any suggestions on how to identify the source of problem, and how to get the second script working?
Update: just found a solution. The problem is related to system PATH. Running this instead solved the problem:
subprocess.call([
"source ~/.zshrc; mvim --servername VIM --remote-silent test.tex",
],shell=True)
I still don't understand why. The executable mvim is always pointing to the same file. Before I did the sourcing, even if I replace the mvim by the absolute path /opt/homebrew/bin/mvim, still the same error.
Here is my .zshrc file for reference:
export PATH="/opt/homebrew/opt/[email protected]/bin:$PATH"
alias python='python3'
alias pip='pip3'
export PATH="/Users/xiaoyu/Repos/university-setup/scripts:$PATH"
export PATH="/usr/local/bin:$PATH"
export PATH="/opt/homebrew/bin:$PATH"
export PATH="/Library/TeX/texbin:$PATH"
test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"
export PATH="/Applications/MacVim.app/Contents/bin:$PATH"
My current guess is: MacVim GUI calls some executables when initiating clientserver. Without /usr/local/bin added to PATH, it fails to locate the executable.
However, I need some help and insight on whether this is a plausible explanation, and how can I test this hypothesis.