-
-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add TRAMP support #29
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this, looking pretty good! I haven't tested it out yet but I spotted a couple of little cosmetic things.
envrc.el
Outdated
@@ -178,9 +191,10 @@ called `cd'" | |||
"Update the current buffer's environment if it is managed by direnv. | |||
All envrc.el-managed buffers with this env will have their | |||
environments updated." | |||
(let ((env-dir (envrc--find-env-dir))) | |||
(let ((env-dir (envrc--find-env-dir)) | |||
(env (envrc--get-process-environment))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a tab here? The alignment is off.
envrc.el
Outdated
@@ -149,6 +148,20 @@ One of '(none on error).") | |||
|
|||
;;; Internals | |||
|
|||
(defun envrc--get-process-environment () | |||
"Returns correct process envirionment for local and remote buffers" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Returns correct process envirionment for local and remote buffers" | |
"Returns correct process environment for local and remote buffers." |
envrc.el
Outdated
process-environment)) | ||
|
||
(defmacro envrc--with-tramp-vec (vec &rest body) | ||
"Binds the tramp vector to VEC and connection buffer to CONN, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This docstring looks wrong (CONN?) and not conformant with checkdoc.
envrc.el
Outdated
@@ -213,16 +227,6 @@ MSG and ARGS are as for that function." | |||
(insert (apply 'format msg args)) | |||
(newline)))) | |||
|
|||
(defun envrc--directory-path-deeper-p (a b) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, thanks for deleting this bit
I tried this out by adding a |
Hey, thanks for your feedback! In my initial implementation, I wrongly assumed that the variables must be set in the tramp connection buffer. I've updated my PR to reflect this. Most normal operations should now work. I also fixed all of your suggestions. However, it seems like shell programs still don't work. Using the test you suggested, |
It seems like |
Thanks for this, I haven't worked much with the tramp machinery, so I appreciate you tackling the issue. |
Sorry for bumping this almost a year old conversation but as a recent migrant into Emacs I would love this feature :-) @siddharthverma314 did you continue working the version posted here? Is there something I can do to help testing this? |
Hey Andi, yeah, I was wondering about this recently too. |
Thanks for your interest! Back when I was writing this, the tramp implementation (to my knowledge) did not support buffer local |
Hi, just wanted to say I'd love this feature too! :) Happy to help test it. |
@siddharthverma314 I haven’t done extensive testing yet, but
if that’s still the case, then buffer-local doesn’t help, because there’s only one relevant buffer per connection. I had another thought that might help – do what you’re currently doing, but add advice to the various TRAMP functions like
which would hopefully then use the appropriate environment for each command (and buffers that don’t have buffer-local values for these vars would just end up setting the connection buffer’s values to to defaults. (There are coarser variants, like updating the connection-buffer’s variables whenever the selected window changes, like via |
👍 if possible, that would be awesome |
@andir did you find a workaround to use tramp with a remote nix shell? |
880e6c3
to
4ece907
Compare
Hey everyone, I've been working on this locally and I think I have an implementation that works ~20% of the time 🤣. I'd love to gather feedback about whether it works or not, but try at your own risk. Or if you find bugs, let me know and I can fix them. Also, thank you @sellout for the inspiration, I ended up implementing an Note that in order to enable direnv over tramp, you will need to set (use-package envrc
:straight (envrc :host github :repo "purcell/envrc"
:fork (:host github :repo "siddharthverma314/envrc"))
:config
(setq envrc-remote t)
(envrc-global-mode)) Thanks for your patience! |
Thanks, @siddharthverma314! I should be able to give this a go tomorrow. |
Nice! In what way does it fail to work the rest of the time? |
Thanks, @siddharthverma314. I've been looking for something like this for some time. I can't get it working yet, though. When I use your sample config I get |
@hso Thanks for the feedback! I'm assuming you tried the obvious, like restarting emacs, running
|
@purcell In my testing, things got slow sometimes or the remote path got messed up, but these might have been problems with earlier versions of the code. For now it seems to run fine, but I definitely haven't tested all cases yet. |
Is this ready to merge? |
Perhaps it's the
Not yet. I want to understand how it works and what the trade-offs are, and I haven't had the time for a deep dive. For example, the changes apparently rely on copying buffer-local environments into the connection buffer "just in time" for commands to be executed there, so I worry about collisions or unexpected lingering effects. e.g. If you have multiple But I think this is promising. |
4ece907
to
cbf7104
Compare
cbf7104
to
1ebacbe
Compare
@siddharthverma314 yes, I tried restarting emacs, running
I don't have that command available, I suppose I have never installed a package for tramp, I'm just using the one that comes with my emacs version:
Sure:
|
Any progress on this? or maybe a workaround. |
with 5c1d1eb, I got I tried with |
"Whether or not to enable direnv over TRAMP." | ||
:type 'boolean) | ||
|
||
(defcustom envrc-supported-tramp-methods '("ssh" "sshx") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I propose adding "scp" "scpx"
here, since they differ only in file transfer method, everything else is the same as for ssh[x]
. At least for me, it works well for scpx.
Is there any progress on merging this PR? At least for me it works well with remote direnv + nix. |
Unsure of the current status, and I don't use the changes myself. The merge conflict looks trivial, but @bbigras reported issues above, maybe due to not having direnv installed on the target machine? |
It looks plausible (or maybe PATH issues on the remote end). At least I use envrc with this PR applied almost every day (both locally and remotely over TRAMP), and didn't have any issues so far. |
Same. In fact, I recently switched to my own fork to test out some unrelated changes, and was immediately affected by the loss of TRAMP support 😆 |
I've resolved this conflict and merged this PR into the main branch. Couple of questions for you all though:
|
Hey! Thanks for merging this PR. Regarding the concerns you raised above:
Sorry for the delay in pushing this through. |
Even the existing tests have been a bit broken for a while tbh. :( I'd be inclined to remove the var anyway if that's the only technical reason for it — worst case would be that we get a few helpful bug reports. |
I'll close this PR to avoid confusion, but feel free to comment further, or open a follow-up issue or PR. |
For Nix home-manager users if you are SSHing into a machine that manages direnv with SSH, direnv will not be found. Use the snippet outlined in this wiki article to solve the problem. https://nixos.wiki/wiki/Emacs#Cannot_find_all_binaries_on_a_remote_system_with_TRAMP This solved my problem since I was running into the same issue as @bbigras |
Hi,
This PR adds tramp support and closes #27 . It has only been tested by me, so I would appreciate it if others could try it out and see if it works for them!