8

Is it considered better to use TRAMP to access remote files on a local copy of Emacs, or to ssh into the remote server and access the files using a remote copy of Emacs in the ssh session?

What are some of the considerations involved in making this decision?

3 Answers 3

12

Since TRAMP uses ssh by default, the real question you are asking is if you should use local or remote emacs to edit remote files. Right?

Is it considered better to use ...

There is no better, just that use cases differ for both local and remote editing.

What are some of the considerations involved in making this decision?

If you normally work with a variety of servers as part of your workflow, then use local Emacs with TRAMP. On the other hand, if you access remote server from a variety of clients, laptops, locations, or devices, then ssh into the server might be more convenient.

The size of the edits and any compilation needs also need to be taken into consideration. You can avoid large file downloads and uploads by using ssh. You probably cannot avoid this, say if you are editing in languages that are not natively supported by the server, but you have the tools locally.

If all your tools are local to your laptop, then using TRAMP makes sense. But if your servers mandate compilation on that machine (for security reasons), then ssh might be more appropriate.

Lastly, if your emacs usage is not dependent on mouse and other input devices (for multiple languages), then ssh is the way to go as it is optimized for keyboard interaction. Otherwise local Emacs with the full GUI interface is what you'd want.

7

I agree with Emacs User: Neither approach is objectively "better". If you don't have any obvious compelling reason to go with one or the other, then it's really just a subjective balance between performance and convenience.

If you need only occasional access to any given server, the ease of using TRAMP ought to trump a low-to-moderate performance hit.

If you will be making moderate-to-heavy use of Emacs with a given server, then running Emacs on the remote server is a more obvious consideration (but by no means a necessity).

Use TRAMP to start with. If you have no issues with performance, then that's likely the best and simplest solution. If the performance hit bothers you, try running it remotely.

You'll also need to decide whether to run GUI Emacs or not. Remote GUI Emacs brings its own performance issues (I do use it when running Emacs inside a locally-hosted VM, but not otherwise). If you usually use GUI Emacs and you'd need to use terminal Emacs remotely, that's obviously another trade-off to consider.

Use whatever feels best to you.

4

A third variant is to mount the remote directories via sshfs and access them via your local Emacs. This has the advantage that you don't have to reproduce your Emacs setup on the remote machine(s) and you can use your local software, such as Git, which might be more up-to-date than on the remote machines.

This approach is, however, not perfect. Problems to do with things such as permissions may occur if you work in the shell both locally and on the remote machine. These can then show up as subtle and hard-to-debug issues with software such as Git.

1
  • 2
    One should keep in mind that running local processes (git, find, grep, etc) on a sshfs directory is going to be significantly slower compared to executing those processes on the same host as the files themselves (which Tramp facilitates, and which you obviously get automatically if Emacs is running remotely to begin with). That can be a pretty major "con" to using sshfs (but it's certainly a useful option to consider, nevertheless).
    – phils
    Nov 29, 2019 at 0:40

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.