reddit / emacs
Has TRAMP ever work for you flawlessly?
shackra · 2022-05-25 20:27
title.
Every single time I try to use TRAMP, I'm always met with File error: Timeout reached or Emacs just plain freeze there. I'd love to edit locally files that exist remotely without any significant setback, but... yeah, for me is impossible.
Config? well, I use Doom Emacs (which I love) and have nothing in my personal configuration related to TRAMP. In Doom, [for the TRAMP hanging forever](https://github.com/doomemacs/doomemacs/blob/3b789752a30419535b328c605957b6b43a9d47fa/docs/faq.org#tramp-connections-hang-forever-when-connecting), they point to the [Emacswiki](https://www.emacswiki.org/emacs/TrampMode#toc7), but come one! I wish stuff just work out of the box :(
Is there any TRAMP configuration that works out of the box and flawlessly?
## some more context:
- zsh 100% on all computers I own/have, including VPS.
- custom prompt on zsh!
- mostly trying to connect with GNU/Linux machines/VPS
- One machine asks for OTP, it looks like this: `(user@remote) Verification code: `
# how I solved my predicament.
[took the advice](https://gitlab.com/shackra/shell/-/commit/905d96684f3ca7b251d48eea77d15e1a2b3ba16c) of simplifying my ZSH prompt. Also, because in some machines I have SSH asking for an OTP on login, I added the phrase `verification code` in `password-word-equivalents`.
Now things works much better, so amazing! Thanks for the tips and the help!!
draxil · 2022-05-25 20:39
Generally tramp works great for me, How are you using it? ssh? What OS?
BettaGeorge · 2022-05-25 20:42
That sounds strange. I'm sure loads of doom users use tramp.
Personally, I have never encountered a single problem with tramp except for an unresolved helm bug. So unless you're using helm, everything should just work out of the box.
7890yuiop · 2022-05-25 20:50
> Has TRAMP ever work for you flawlessly?
Yes.
7890yuiop · 2022-05-25 21:03
> they point to the Emacswiki, but come one!
You mean *reading?* Oh, the horror.
> Is there any TRAMP configuration that works out of the box and flawlessly?
This is networking which means there's a *vast* array of things which can go wrong. Your expectations of something that magically handles *any possible scenario* are unreasonable. Tramp works perfectly for most people most of the time, but when you're asking something to interact with an arbitrary remote system there are either assumptions which must be made, or configuration needed if those assumptions are invalid.
People have taken the time to document troubleshooting notes at the Wiki so I suggest you actually take advantage of that.
Tramp will also log a lot of information if you ask it to, which may help you to figure out what's going on. `C-h i g (tramp)Traces and Profiles`
shackra · 2022-05-25 21:06
I've updated my post providing more context
shackra · 2022-05-25 21:07
not a helm user, but yeah it fail to works as expected. I've updated my post providing more context
draxil · 2022-05-25 21:11
zsh causes a bunch of those freeze schenarios on the wiki. did you work through tramp
hangs #3?
shackra · 2022-05-25 21:15
>>they point to the Emacswiki, but come one!
>
>You mean reading? Oh, the horror.
no need to be pedantic, I've naturally read the Emacswiki and so far, nothing have changed. Probably the failure is somewhere between the remote zsh and my machine.
7890yuiop · 2022-05-25 21:32
> I've naturally read the Emacswiki and so far, nothing have changed.
You said none of that in your original text, so it came across as "That's too hard, I'll ask reddit instead".
If you've tried things already, tell people what you've tried, and what the outcomes were -- it saves time and bother.
fiverniner · 2022-05-25 21:33
Do you have a custom zsh prompt on the machine you are connecting to by any chance? If so, tramp may not be able to detect your shell's prompt, which can cause the indefinite hanging.
If so, you need to set `tramp-shell-prompt-pattern` variable to an appropriate pattern to detect your shell prompt.
anaumann · 2022-05-25 22:08
I've had good results by just using sshx for the connection string to make tramp use /bin/sh instead of zsh and it got rid of all my timeout problems :)
shackra · 2022-05-25 22:27
yeah, I actually do have a custom prompt
shackra · 2022-05-25 22:28
I tried it per the Emacswiki, but probably some else is causing the hang :(
slashkehrin · 2022-05-25 22:50
I vaguely remember it freezing when doing GREP searches with lots of files that contain a lot of text. That was 3 years ago though. Otherwise it worked surprisingly well for basic text editing.
Nice_Elk_55 · 2022-05-25 23:45
It's not just you, it's somewhat buggy. Every time I tried using it for a few hours, eventually it caused emacs to freeze completely. It's also a bit slow even with ControlMaster. That said, if you can't connect at all, it's probably an issue with your prompt or zsh. Try temporarily setting your shell to bash and compare.
oantolin · 2022-05-25 23:45
I'm not a heavy TRAMP user, but I have been using it a few times a week for years now, for remote file management, editing and shells, without a single problem that I can remember.
styrg · 2022-05-26 00:39
It works out of the box for me in spacemacs. Its not fast but it works.
ispinfx · 2022-05-26 00:51
Tramp requries a very smooth/fast network connection. Otherwise, it's just pain.
drm940 · 2022-05-26 00:56
I use Doom emacs and it works out of the box, at least for simple ssh file editing, but is too slow to the point I just don't use it (I only need it for ssh).
CorysInTheHouse69 · 2022-05-26 01:27
Remove it then
dilap · 2022-05-26 01:36
once many years ago after much effort i had it working perfectly. then something changed (i don't know what) and it stopped working; i gave up. no more trampin' for me!
but it is possible...
404cn · 2022-05-26 01:53
Do not change prompt on vps, even in /etc/zshrc.
super-linux-nerd · 2022-05-26 02:42
I do all of my work over SSH via Tramp. Magit, dired, vterm, consult... Everything Just Works.
sjatkins · 2022-05-26 02:55
Try sshx instead of ssh for connecting to remote machine. This solved a lot of these problems for me.
howardthegeek · 2022-05-26 03:29
Add that prompt (it at least some of the details) to your tramp configuration. Works well for me after I did that
ambihelical · 2022-05-26 05:04
I started using tramp at the start of the pandemic. To answer your question, it worked perfectly.
Not not really, it would hang up maybe 1 out of 10 times, just enough to drive me crazy.
The problems stopped when I got a job where I didn't have to edit files remotely.
I'm feeling much better now.
invsblduck · 2022-05-26 05:11
I love the idea of this. Like OP, I've never seen it perform. Always wondered if people really use it. Tends to be unusably slow and will freeze entire frame while it hangs. Such sad.
AsterOps · 2022-05-26 06:16
[https://www.gnu.org/software/emacs/manual/html\_mono/tramp.html#Frequently-Asked-Questions](https://www.gnu.org/software/emacs/manual/html_mono/tramp.html#Frequently-Asked-Questions)
Some of the faq (or manual in general) helps me improve performance.
wargxs · 2022-05-26 06:20
Works fine for me! Make sure you use the latest version from elpa
Greedy_Animal_6101 · 2022-05-26 06:21
TRAMP works perfectly... if you nail the configuration first-time. Spelling out the address of a local running machine usually works, unless there's any issue anywhere then Emacs hangs / doesn't communicate it too well. I always had to just find it myself, luckily that had usually been straightforward enough. I have a routine now and connecting to setup machines I've already been on always works.
WLrMGAFPGvD6YRBwUQa4 · 2022-05-26 07:53
It works reasonably well for me, the only issues I've seen are with version control. Happily, I don't use emacs for that so I was able to fix it with `(setq vc-handled-backends nil)`. If you actually use version control through Emacs though, you'll probably want something smarter.
worthless-trash · 2022-05-26 08:18
The alternative is to have
[[ $TERM == "dumb" ]] && unsetopt zle && PS1='$ ' && return
At the top of the .zshrc , so that it presents a sane prompt to emacs.
worthless-trash · 2022-05-26 08:28
For:
(user@remote) Verification code:
​
See :
​
[http](https://www.gnu.org/software/emacs/manual/html_node/tramp/Remote-shell-setup.html)[s://www.gnu.org/software/emacs/manual/html\_node/tramp/Remote-shell-setup.html](https://www.gnu.org/software/emacs/manual/html_node/tramp/Remote-shell-setup.html)
Set up: tramp-password-prompt-regex
(customize-set-variable
'tramp-password-prompt-regexp
(concat
"\^.\*"
(regexp-opt
'("passphrase" "Passphrase"
;; English
"password" "Password"
;; Some System with OTP:
"verification code" "Verification code")
t) ".\*:\\0? \*"))
I haven't tested the above, but it seems like the right path.
holgerschurig · 2022-05-26 08:49
Yes, worked for me whenever I used it.
Linux-to-Linux, and of course before I used Tramp, I used ssh / rsync-over-ssh already.
Shells are however bash or even just dash (e.g. inside a container).
El-Raton · 2022-05-26 11:40
Kinda: chokes on my custom zsh prompt, so I have a special simple prompt when zshrc senses a dumb terminal:
```
# fix for emacs tramp
if [[ "$TERM" == "dumb" ]]; then
unsetopt zle
PS1='> '
HISTFILE=~/.tramp-histfile
else
prompt oliver boldblue
fi
```
loskutak-the-ptak · 2022-05-26 12:49
For me, tramp works flawlessly without any special configuration as long as I am on fast and reliable connection. I get frequent complete freezes (not even repeated SIGUSR2 kills working) when the connection is not good.
JDRiverRun · 2022-05-26 13:52
For dealing with remote paths, if you are running Emacs on MacOS with a version of Tramp before 2.5.1.3, there was a major but [subtle bug](https://www.mail-archive.com/tramp-devel@gnu.org/msg05695.html) which caused tramp to spawn a shell command for remote directories hundreds of times per remote file-path completion. I also use zsh (locally, not the remote), which is quite slow to start, especially if you load options. This led to extreme inexplicable slowdowns working with remote paths, gone after the fix.
InternalImpact2 · 2022-05-26 14:09
Ensure that your prompt hasn't any funny symbols
FrozenOnPluto · 2022-05-26 14:40
I used to have a lot of TRAMP issues in the past, but for the last couple years especially its been fantastic; caveat that you need pretty fast connection since it adds a few layers, and you'll want to be on pretty recent Emacs with up to date MELPA pulls etc, to get best compatibility. ie: Using magit over TRAMP or ztree for directory compare over TRAMPs .. that'll murder you if you're not up to date-ish.
There are certainly some gotchas of course, for packages that assume everything is local, or in performance, but generally the plus-side far outweights the negatives. If there are negatives for a given connection, its usually supper annoying and avoided, but for my use cases it works well for 90% of what I need it do.
For ssh, you may want to look into twaking the ssh connection settinghs in your user account ssh config, for instance to change timeouts or set to re-use same connection for multiple connections (multi channel etc); ie: I tend to open a couple of shells to a given box, outside of Emacs, plus some magit and file open/save/etc, so its nice if ssh and just join existing sessions, to keep performance up..
super-linux-nerd · 2022-05-26 15:39
The secret sauce for me was setting up ssh controlmaster for persistent, reusable connections. Tramp wants to use its own controlmaster settings which are kinda bad.
shackra · 2022-05-26 16:54
thanks for the pointer!
I really think TRAMP should fail with an error if he cannot match anything output to it from remote, in my case it keeps trying and trying
invsblduck · 2022-05-26 17:16
Cool. I've worked in Linux automation my entire career (decades now), so I'm quite familiar with multiplexing in OpenSSH via `ControlMaster`. I've never looked at TRAMP in depth before, so what does it do to use this feature poorly?
shackra · 2022-05-26 21:19
I [just did that](https://gitlab.com/shackra/shell/-/commit/905d96684f3ca7b251d48eea77d15e1a2b3ba16c). I'm crossing my fingers now.
shackra · 2022-05-26 21:34
I marked my post as solved, but, do you care to elaborate on this?
shackra · 2022-05-26 21:35
yeah, this did the trick too. I've edited my post with the solution to my problem.
shackra · 2022-05-26 21:36
[did something like that](https://gitlab.com/shackra/shell/-/commit/905d96684f3ca7b251d48eea77d15e1a2b3ba16c) in my case, indeed, this really helps.
shackra · 2022-05-26 21:36
I was able to fix TRAMP for my use case, you can read the OP for details on the solution.
Thank you for providing help!
onetom · 2022-05-27 03:00
what system are you ssh-ing from and into?
I tried from zsh on macOS to off-the-shelf bash on NixOS, Ubuntu, Amazon Linux and to another or even the same zsh on macOS and*none* of them worked worked without sweat and tears!
I just gave it a try again from one macOS to another, both were on zsh and had Nix installed, but in an `eshell` running `cd /ssh:remote:my/project/`, `which clojure` just said "clojure is not found on the path".
finally somehow made it work, but I'm not even sure what was the issue... I've just heard about /sshx: from blog posts and SO answerers, then about `tramp-remote-path 'tramp-own-remote-path` customization.
then I've ended up needing to tweak my already customized .bash_profile, though my default shell is zsh. I was calling `eval "$(direnv hook bash/zsh)"` from both .bash_profile and .zshrc, but the one in .bash_profile seemd to cause issues.
then finally, when my eshell could find clojure (which was installed by `nix-env -i`) running CIDER was complaining about connectivity and reconned turning on ssh-fallback. doing that finally allowed me to open a remote Clojure REPL, but eventually I figured I can avoid the need for ssh-fallback by putting `{:bind "0.0.0.0"}` into my `/ssh:remote:my/project/.nrepl.edn`.
I still don't have the exact remote environment I would expect, because direnv is not integrated, though I have purecell/envrc installed in Emacs and it works locally.
I also have the following in my ~/.ssh/config:
host remote
hostname remote.local
user my-remote-username
so my tramp path can be that short.
I also use ZeroTier One to make my office machine (remote.local) appear as if it was sitting on my local physical network; that's why I can refer to it with this .local multicast DNS (aka mDNS) domain name.
of course I also have the famous TERM = dumb incantation in my .zshrc to set PS1 to something simple and tweak a bunch of shell options, which I still don't understand.
so I'm not happy, when people are suggesting "just use TRAMP", as if it would be something trivial, when in reality, TRAMP is still a finicky beast and it's very likely that you have learn a lot to use it seamlessly...
for just file access, it's not that bad and if all your remote programs are installed into FHS directories, so u don't rely on special PATH env var, like in case of Nix, then you might have more luck, but the special prompt is still likely to trip u up.
onetom · 2022-05-27 03:05
I tried to use ControlMaster but I remember having issues with ssh-agent forwarding and shells hanging, so I gave up on it eventually.
I would also be interested in under what conditions does it work for you.
onetom · 2022-05-27 03:15
what would you count as a "non-arbitrary remote system"?
I also have the feeling that ppl, who are TRAMPing from/to Window/macOS have more problems, than ppl using popular Linux distros?
Maybe because Emacs largely works on Win/Mac, it sets up ppl to expect a more turn-key TRAMP experience too?
Also, ppl who used similar tech, like VS Code remote workspace (or whatever it's called) are used to a zero-config, just-works experience?
Code camps are also advertising oh-my-zsh fanciness, which breaks TRAMPs default prompt detection?
7890yuiop · 2022-05-27 03:47
> what would you count as a "non-arbitrary remote system"?
I can't tell if that's a genuine question, but in case it was:
All systems are "arbitrary" for the purposes of that comment. The point being that any given system *might* be configured in such a way as to invalidate some assumption that Tramp makes. Most of them aren't. But they could be.
onetom · 2022-05-27 04:09
it was a genuine question.
I had to ask it, because I felt you might be implying some definition of non-arbitrary, which I'm blind to.
We are all biased because of our life experiences and might have this concept of a "common machine setup", which we encounter the most, and expect that setup to just work, by the virtue of being "common".
I'm very aware, that by using Nix, I step outside of the Filesystem Hierachy Standard, a presence of which is an assumption built into a lot of software.
Mixing the proprietary macOS into the picture might also invalidate a bunch of assumptions, like supported command options.
Then zsh is also not the most common shell; I only switched because macOS made it the default and it's just easier not to fight it :)
Used fish before, but its non-bashisms were a constant drag.
Thanks for taking the effort and sharing your thoughts on such abstract things!
by_wicker · 2022-05-27 10:51
>which are kinda bad.
Could you elaborate?
by_wicker · 2022-05-27 10:57
Yep. I have to work via an AWS jumphost and initiating a connection takes 6s+. Opening a terminal takes about 1s. It does dozens of round trips to establish the capabilities and characteristics of the remote one by one.
frozeninfate · 2022-05-28 05:25
Only issues I had were to have remote use /bin/sh if tramp and modify tramps path to use remote path. After setting those two things its been flawless and i use it for everything related to remote machines, sudo, docker, etc.
mavit0 · 2022-05-29 22:51
Consider using the `sftp` method, which uses GVFs as it's backend. Compared to the shell-based methods, it's faster, less fragile, but less powerful.
ispinfx · 2022-09-15 04:38
I have `eval "$(direnv hook bash)"` in `.bashrc` in the remote server, and after adding `(add-to-list 'tramp-remote-path 'tramp-own-remote-path)`, running `C-c C-c` (`comint-interrupt-subjob`) in a `M-x shell` session causes the remote shell process dead.
Do you have this issue?
onetom · 2022-09-29 07:13
i use IntelliJ, without remote connections, primarily, so I don't think I will have time to try, what your described, anytime soon. maybe next year.