0

This is an emacs & magit version of the following question, with an added twist.

https://stackoverflow.com/questions/72839263/access-python-interpreter-in-vscode-version-controll-when-using-pre-commit

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.

10
  • I'm a bit confused... git runs the pre-commit hook, not Emacs; so why would Emacs need to know anything about the PATH required by a git hook?
    – phils
    Aug 24, 2022 at 4:00
  • My guess is that your pre-commit hook is failing in general without a supporting PATH, and so you're wanting Emacs to call git with a custom environment to get around that. I think adding to tramp-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.
    – phils
    Aug 24, 2022 at 4:20
  • 1
    It will if it's in one of the tramp-remote-path directories. Use magit-remote-git-executable though.
    – phils
    Aug 24, 2022 at 6:15
  • 1
    You can also set magit-remote-git-executable to an absolute path to the script, of course, in which case you don't need to touch tramp-remote-path at all.
    – phils
    Aug 24, 2022 at 11:06
  • 1
    Btw, I think "even different for each branch" makes it significantly less practical to do anything more than that on the Emacs side, so I'd just do that and, if poetry is something which is slow to execute, then make your wrapper script only call it conditionally (i.e. if a git commit command is actually being used, as you don't care about pre-commit hooks in other circumstances).
    – phils
    Aug 24, 2022 at 11:14

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.