This is an emacs & magit version of the following question, with an added twist.
The self-answer there (by Mehdi) also works for me: just start emacs as a subprocess of poetry (with poetry run emacs -nw
or similar) and poetry will set up the PATH which emacs inherits, and everything works fine.
The twist is that I also want to work with remote repos, via tramp. Understandably, poetry knows nothing about emacs and tramp, so although magit itself magitally works over tramp, my pre-commit hooks which are managed by poetry do not work.
git
runs the pre-commit hook, not Emacs; so why would Emacs need to know anything about the PATH required by a git hook?git
with a custom environment to get around that. I think adding totramp-remote-path
will handle that. Alternatively you could update the pre-commit hook so that it knows where to find the things it depends upon.tramp-remote-path
directories. Usemagit-remote-git-executable
though.magit-remote-git-executable
to an absolute path to the script, of course, in which case you don't need to touchtramp-remote-path
at all.poetry
is something which is slow to execute, then make your wrapper script only call it conditionally (i.e. if agit commit
command is actually being used, as you don't care aboutpre-commit
hooks in other circumstances).