timhae · 2022-09-05 14:36
Dear all, using doomemacs on NixOS I have trouble getting tramp to work nicely through zsh with projectile/magit/etc. I have read [this](https://www.emacswiki.org/emacs/TrampMode#h5o-9) section of the emacs wiki about zsh but none of the options given there make zsh work with tramp. Currently I have:
if [ $TERM = "tramp" ]; then
unset RPROMPT
unset RPS1
PS1="$ "
unsetopt zle
unsetopt rcs # Inhibit loading of further config files
return
fi
So I have to resort to `sshx` which works but then magit fails to find git, projectile can not initialize project caches and many other unpleasant things.
I have tried the following settings in various combinations to no avail:
(setq projectile-file-exists-remote-cache-expire nil)
(setq projectile-enable-caching t)
(add-to-list 'tramp-remote-path 'tramp-own-remote-path)
(setq-default projectile-indexing-method 'alien)
(setq tramp-connection-properties
'(("/sshx:server:" "remote-shell" "/run/current-system/sw/bin/zsh")
("/sshx:host:" "remote-shell" "/run/current-system/sw/bin/zsh")
("/ssh:server:" "remote-shell" "/run/current-system/sw/bin/zsh")
("/ssh:host:" "remote-shell" "/run/current-system/sw/bin/zsh")
("/ssh:user@host:" "remote-shell" "/run/current-system/sw/bin/zsh")
("/sshfs:" "direct-async-process" t)))
(customize-set-variable 'tramp-encoding-shell "/run/current-system/sw/bin/zsh")
(setq tramp-terminal-type "tramp")
Any ideas what else I could try?
podtatranec · 2022-09-05 19:14
Pretty sure the documentation is telling you to check for term equals dumb not tramp.
Edit:nvm, noticed you change the defaults
CrunchyChewie · 2022-09-05 19:47
Can you describe what "work nicely" means? Do you have any functionality at all? Reduced functionality? Any specific error messages?
timhae · 2022-09-05 20:13
sshx connection works fine but there projectile does not initialize correctly, i.e. it does not build a cache, there is no error it just aborts building the cache after a second or so. Also emacs can not find the git executable for magit. I would like to use ssh with zsh and be able to use projectile and magit.
sigsegv0xb · 2022-09-05 20:55
sshx runs something like this: `ssh -t -t -l <user> -o RemoteCommand='/bin/sh -i' <host>`
So it uses /bin/sh, meaning you need to make sure your path is set in `~/.profile`. You can run this SSH command yourself to make sure it's working.
Regarding ZSH, I recently set up the same thing and was making a dumb mistake in my config. I figured this out by manually SSHing with `TERM=dumb ssh <host>`. I'd recommend you try that and make sure that works.
If you're still having issues, set `tramp-verbose` to 6 and see what's going on in the logs.
snafuchs · 2022-09-06 02:41
You may be interested in the `tramp-remote-path` variable. Using nixos myself as a tramp destination and this works (but, alas, you need to change my homedir out):
```
(setq tramp-remote-path
‘(tramp-own-remote-path “/run/wrappers/bin” “/home/asf/.nix-profile/bin” “/etc/profiles/per-user/asf/bin” “/nix/var/nix/profiles/default/bin” “/run/current-system/sw/bin”))
(add-to-list ‘tramp-remote-path ‘tramp-own-remote-path)
(dolist (p ‘(“/run/wrappers/bin” “/home/asf/.nix-profile/bin” “/etc/profiles/per-user/asf/bin” “/nix/var/nix/profiles/default/bin” “/run/current-system/sw/bin”))
(add-to-list ‘tramp-remote-path p))
```
Edit: forgot to mention `(setq enable-remote-dir-locals t)` which is also great if you do anything direnv-related.
timhae · 2022-09-06 10:52
Thanks for the replies, in the end I just set `(add-to-list 'tramp-remote-path 'tramp-own-remote-path)` and using sshx everything works now (git, projectile, ...). I guess there is no point in using zsh for this anyways.