dajva / rg.el

Emacs search tool based on ripgrep
https://rgel.readthedocs.io
GNU General Public License v3.0
471 stars 38 forks source link

Tramp and rg #100

Closed apmanol closed 2 years ago

apmanol commented 3 years ago

Hello and thanks for this nice little magic package.

Since we get addicted to it's use and the current trend is remote working, the combination of tramp and rg.el isn't very smooth. Checked already the issue #43 but I couldn't find a way to work rg in remote-tramp connections. So the problem is that is uses the rg-executable in the host not in the remote machine.

/bin/sh: line 2: /home/local-machine/.cargo/bin/rg: Permission denied

rg exited abnormally with code 126 at Tue Oct  6 23:25:54

Do you have any suggestions for configuration setup in order to help understand that it works in remote-tramp buffer and use the rg in the remote computer? Some approach in other packages is this.

thanks a lot for any tips!

-Apostolos

dajva commented 3 years ago

I have not used tramp like this myself but my understanding is that you either need to customize rg-executable to the binary name without path, iow rg. This would allow the local or remote shell to locate the binary property on each host. This may need some tweaking of tramp and local config to work. See https://www.gnu.org/software/emacs/manual/html_node/tramp/Remote-programs.html Alternatively you can use the full path, if rg can be found at the same place on both the local and remote machine.

dajva commented 3 years ago

I am very interested in if you get it working and in that case, how you solved it. I think the rtags solution looks reasonable to have this more automatic in this package.

apmanol commented 3 years ago

Sorry, but I didn't have the time to search deeper in the issue, although the emacs-tramp combination is in daily usage. That's the reason of asking the issue :-)

ghost commented 3 years ago

This might be a silly suggestion but can't you just mount the remote drive? I had so much problems with tramp in general, I find it easier just working with mounted directories.

apmanol commented 3 years ago

Indeed tramp has some issues, but unfortunately there isn't the possibility of mounting the remote drive (at least in my case), so it would be nice to have rg working remotely.

Ergus commented 2 years ago

The best way to make this work with tramp effciently may be to use connection local variables on remote buffers. I made a similar patch for company-gtags a while ago:

https://github.com/company-mode/company-mode/blob/c25f1fbc3850e36e6521b77fa1641d5583365d8b/company-gtags.el#L71

I can try to make a pull request for this feature if you like.

dajva commented 2 years ago

Thanks to @Ergus suggestion this should work now without user interaction by default. The implementation is behind the rg-executable-per-connection custom var so it's possible to get back the old behavior if needed.