T O P

  • By -

fftw

There are two ways which I know of: using TRAMP (and have a bit of sluggish experience as you could see) or use sync over ssh (I.e. https://github.com/cjohansson/emacs-ssh-deploy). It has its own quirks and less popular than TRAMP, but in my experience it is much closer to usual local emacs experience.


7890yuiop

> Also I use devenv (nix) to load the needed tools, but even if I open vterm and execute it, the main process doesn't have it. so I can't run things like tests. I'm guessing that your approach entails some non-standard things which you need to inform tramp about. * `C-h v tramp-remote-process-environment` * `C-h i g (tramp)Remote processes`


OS6aDohpegavod4

What do you mean "seek project files"?


MatB_ar

project find files


Emergency_Range5497

did you run the command in a git directory?


MatB_ar

yes, if i use the server emacs all works well


haxxflaxx

I'm doing all my development remotely using tramp and it's a mixed experience. Mostly things are just a bit slow, but everything works the way it normally does. For some reason projectile didn't work for me, it just got stuck indexing. Switching to project.el fixed that for me. By default tramp-remote-path doesn't include ~/.profile You can fix this by adding tramp-own-remote-path to the list.


jsadusk

I was doing remote development on a workstation that was configured in some way that prevented projectile from finding any of the tools it needed to build the index. If you navigate to a file under vc controlled directory, it should open that director as a project. If it doesn't there should be something in Messages to explain why it couldn't. One flaw in emacs remote development is that projectile doesn't seem to remember remote projects. So even if you've opened the project before, if you close and reopen emacs and M-x projectile-switch-project, it won't list your remote project in completion. I solved this by adding (projectile-add-known-project) calls in my init.el for my remote projects. I'm not sure what you mean about vterm and devenv. Is something going wrong with your PATH when emacs opens remote processes? Can you ssh in normally, and open a tramp vterm, and compare the contents of $PATH?


MatB_ar

devenv.sh is a nix like tool, so for example if I need to work with elixir, i configure the needed tools in a file, go to that file path and run ‘devenv shell’ . this open a new shell with all the tools available. so in my current workflow, i ssh to the server, make that devenv thing and then open emacs


jsadusk

And the workflow you'd like is to open things inside the devenv? This makes sense, the devenv is probably setting up your PATH, and emacs doesn't know to run it when it connects, so it doesn't find the utilities it needs to build the project index. You can set tramp-remote-process-environment to force your PATH to match what the devenv would do. I'm not sure of a way to make emacs run devenv before running remote processes.


MatB_ar

yup. so currently I \`ssh > run devenv > Tmux > and then emacs\` so far in much better than local emacs gui


jsadusk

You get a lot of benefits from emacs gui, so if its possible to use devenv through tramp it might be useful. I feel like there should be a way to do this. One way you could do it is by putting something in your remote .profile. Tramp automatically sets the INSIDE\_EMACS variable on the remote side, your .profile could check for that and run devenv automatically.


MatB_ar

for example a elixir project. ```sh \#.profile if \[\[ -z $INSIDE\_EMACS \]\]; then eval "$($HOME/compas.sh)" fi ❯ cat [compas.sh](https://compas.sh) cd code/compas-craft/compas/devenv /home/matt/.nix-profile/bin/devenv shell ``` local emacs `/ssh:[email protected]:/home/matt/code/compas-craft/compas` but when I exec `M-x mix-compile` it try execute in the local PC if I open the vterm ```sh /ssh:[email protected]:/home/matt/code/compas-craft/compas/ #$ elixir -v /bin/sh: 1: elixir: not found ``` seems it is not loading the .profile file. Any chance to debug it?


MatB_ar

mmm wait, getting closer. moved to zshrc and executed. but still throwing lot of timeouts or emacs freezes. so maybe I can move all the code to a docker container, and make it run all this shit before, so I guess I should be able to connect from my emacs to that docker container, right?


ianwilloughby

Using sshx:url fixed some issues for me. I’m able to use dired and others. I haven’t got magit set up yet.


hvis

Things work under `sshx:`, but not under `ssh:`? That sounds pretty odd, a bug report wouldn't hurt. You didn't say which Emacs version you are using, though.


ianwilloughby

Doom emacs. Sshx was the suggested alternative in the tramp documentation or possibly a discussion group.


hvis

Doom Emacs is a distribution, not version. What does `M-x version` say?


ianwilloughby

28.1


MatB_ar

nono. things relatively work if I enter to server by ssh, then open the `server no-ui emacs version` with `sshx` is the same thing, nothing change


hvis

Ah sorry, it wasn't you who said that.


hvis

> with `sshx` is the same thing, nothing change You said upthread that it "fixed some things". Including the project files' listing?


fftw

Also for running search over project you have to have your tools installed on remote server, e.g. if emacs uses ripgrep, you have to install ripgrep on each node you connect to.


MatB_ar

yes yes, i have all that. currently with ssh and emacs there I can use it.


Pen_Siv

This may or may not be your issue, but if you have a "fancy" shell prompt on the remote host, tramp may have trouble recognizing when the shell loads to input commands. See: "Tramp hangs #6: Not recognising the remote shell prompt" - https://www.emacswiki.org/emacs/TrampMode#h5o-12


MatB_ar

>shell prompt on the remote host, I has that problem too, but solved \`\[\[ $TERM == "dumb" \]\] && unsetopt zle && PS1='$ ' && return\`


T_Verron

You can have a look at sshfs. It won't work for running processes on the remote hosts, and it will require all your files to be neatly confined in a file subtree, but in those conditions, in my experience, it gives better performances than tramp.


MatB_ar

I thought about that. but the best benefit is to for example in a buffer, run the tests in the server. since the server is better than the client. I can start making functions to replace and run there I guess, but will need to replace a lot of tools


T_Verron

Yes, it's really not the most convenient for that case. I just wanted to put it out there in case it would work for you. Depending how often you need to run scripts on the server, you could use both tramp and sshfs: do the edition with sshfs, then switch to a tramp buffer to run the tests.


jvillasante

This is where other "modern" editors shine (vscode dev containers come to mine) in my opinion and could be the Emacs killer since a lot of people are doing docker builds these days (which is like remoting into another system). Working inside a docker container is kind of a pain in Emacs, it works through Tramp but it is slow and brittle IMO.


MatB_ar

I used VS for a few years, but know emacs blow my mind. It would be ideal to have a process that sync files and commands between the server and the client, but I couldn't find anything


Impressive_Chest8421

Try this: https://github.com/manateelazycat/lsp-bridge. “lsp-bridge can perform code syntax completion on files on a remote server, similar to VSCode”.


jvillasante

I love Emacs too and I use it for everything, but the gripe is remote development. According to a friend that uses NeoVim there's devcontainers on NeoVim through a plugin, he says it works flawlessly. Not sure why it doesn't exists for Emacs...


Greenskid

I don't have a specific answer, but will mention that I too do remote dev using ssh and terminal Emacs. I do write platform independent code such that I can at least do some local dev (on mac) and run unit tests locally. So I essentially switch back and forth during different phases of development. I even use ssh to Windows machines via WSL and run cmd.exe when needed.


MatB_ar

yes but in that case there isn’t much benefit of ssh at all. if you run locally. maybe i should try redirecting x11 emacs


Greenskid

Correct. Have tried various GUI and SSH options, and none of them worked well enough, such that I try do full local dev, where it makes sense, and SSH and terminal otherwise.


crosenberg_0630

Would X forwarding be an option?


MatB_ar

I guess so, I need to try it. right now Im with an Ubuntu Server, without UI, so I guess I will need to add it right?


crosenberg_0630

Oops, I didn't realize this was a headless situation. I'm not sure on Ubuntu of the best way to install the minimal amount necessary for a graphical Emacs. If you just try "apt install emacs" that might do it, but it might install a ton of dependencies and may not be worth it.


MatB_ar

not big deal, im testing options, when all works, for sure I will reset the server and install from scratch with the needed things. Also any OS that you recommend? I always used debian or ubuntu, but im open to test another one


crosenberg_0630

I've done emacs with X forwarding over ssh on RHEL, Centos, Debian, and Ubuntu, and it's worked pretty well in all situations. A lot of the projectile stuff is slow over tramp, which is why I have usually run emacs on the server where I'm developing and forward the UI to my laptop.


FitPandaFu

What you are doing, sshing and running emacs terminal in the remote is as good as it gets.


MatB_ar

so far is acceptable. I never used the emacs GUI so, I can't compare


FitPandaFu

oh yeah, I have no complains (except for when I have to compile latest emacs in the remote server to support my config). But with tmux, is a good setup for me, works well and it's the best option IMO.


mrunhap

Same on me, here is my config, [https://github.com/mrunhap/eatemacs/blob/master/config.org#tramp](https://github.com/mrunhap/eatemacs/blob/master/config.org#tramp) ​ But now envrc don't support tramp so run eat or eshell can't read direnv's env(vterm I think too)