0

I'm new to using Tramp and have set it up to work with a remote host. However, on that remote host, I need to execute module load git before I can use git. I've tried adding that to my remote .bash_profile but my local Emacs (Tramp) doesn't seem to see it.

I also tried creating a git.sh on the remote host that checks if git was loaded and loads it if not, and then passes all other arguments to the real git. That script is:

#!/usr/bin/env bash

if [[ $(module list 2>&1 | grep git) == "" ]]; then
  module load git
fi

git $@

And then telling Magit to use that git with (setq magit-remote-git-executable "/home/<user>/bin/git.sh"), but this also did not work.

Is there a way I can get Tramp or Magit to execute commands before running git?

Edit

My current config is:

(use-package tramp
  :ensure nil
  :config
  (setq tramp-default-method "ssh")
  (setq tramp-default-remote-shell "/usr/bin/bash")
  (setq explicit-shell-file-name "/usr/bin/bash")
  (setq tramp-sh-extra-args '(("/bash\\'" . "-l")))
7
  • I think Tramp uses /bin/sh by default (most cross-platform), try putting your module load .. in ~/.profile. You could enable debug in Tramp and inspect the actual commands, I think they get echoed to *Messages*
    – suvayu
    Jul 8 at 13:59
  • Maybe this helps: (info "(tramp) Remote shell setup")
    – suvayu
    Jul 8 at 14:06
  • See Edit - I'm using bash on remote host.
    – mankoff
    Jul 8 at 14:13
  • Did you run Tramp in debug mode and look at the commands? IIRC, Tramp might even be passing --norc to get a consistent prompt that can be parsed reliably. This has always been a bit difficult to setup with Tramp.
    – suvayu
    Jul 8 at 14:36
  • for debug messages: emacs.stackexchange.com/a/45053/2093
    – suvayu
    Jul 8 at 14:45

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.