-
Notifications
You must be signed in to change notification settings - Fork 47
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
Copying files over TRAMP #37
Comments
I am planning to bring in |
We already have multi-stage and asynchronous copy/paste facilities in Dirvish (`dirvish-yank` command). This commit brings a few new commands that serve for other purposes but have similar mechanism as `dirvish-yank`, they are: - `dirvish-move` - `dirvish-symlink` - `dirvish-relative-symlink` - `dirvish-hardlink` Note that all of them are also asynchronous and work on both localhost and remote host.
Please checkout the latest commit, I don't have time to test it for now, so any feedback/bug report is appreciated. Cheers. |
I could not get it to work over ssh. For
Edit: To clarify I only tried moving files on the remote host not from the remote to the local or the other way around. Should both work? |
I have ssh config looks like this. TCPKeepAlive yes
AddKeysToAgent yes
AddressFamily inet
Host alex
HostName myhost.name
User root
Port port_number
IdentityFile ~/.config/ssh/id_rsa This is how Peek.2022-05-06.22-11.mp4remote to local / local to remote works in a similar way (just without overwrite prompt because rsync handles that) I haven't tested copying files from remote-A to remote-B, not sure if it works. Does the file preview works over TRAMP? Do you have any special config for TRAMP or ssh? |
Just tested with kubernetes pod (via kubel), no luck - copying not working.
Also no Dirvish-yank buffer appears |
This buffer won't popup automatically. (switch-to-buffer dirvish-yank--buffer) |
I have no idea why (defun dirvish-yank--execute (cmd)
"Run yank CMD in subprocesses."
(let ((process-connection-type nil)
(procname (format "*Dirvish-yank @ %s*" (current-time-string))))
(start-process-shell-command procname dirvish-yank--buffer cmd))) Then try (switch-to-buffer dirvish-yank--buffer) |
For me, it is some permissions issue. This shows up instead of preview and in the yank buffer logs. Normal dired operations work correctly. Is some extra setup required for dirvish? I do not have ssh-askpass installed on either machine. Should it be necessary?
I am connecting to a local computer over ethernet with a password only. I have no ssh or TRAMP configuration. For whatever reason, the username shown at the end is not the one I used to connect to the remote host with; it is my local username (not sure if that is a problem). |
This is the excerpt from dirvish.el that in charge of the file preview on remote host. (dirvish-define-preview remote (file)
"Preview files with `ls' or `cat' for remote files."
(when-let ((local (file-remote-p file 'localname)))
`(shell . ("ssh" ,(file-remote-p file 'host) "test" "-d" ,local
"&&" "ls" "-Alh" "--group-directories-first" ,local
"||" "cat" ,local)))) What it does is basically composes and issues a shell command looks like this: ssh foo test -d /path/to/file && ls -Alh --group-directories-first /path/to/file || cat /path/to/file The # other configs for performance
# ...
Host foo
HostName foo.name # in the form of "google.com"
User root # the login username
Port port_number # usually 22
IdentityFile /path/to/identity_file If I run this command in the terminal, I'll get the text content or directory listing for that file, which is the same content being displayed as preview inside of dirvish. In other words, if this shell command cannot work properly, the preview cannot work either. The same principle applies to
All I installed is the openSSH on Arch, nothing else. Other than that, I've copied the pubkey to the "foo" using I did not even tried to use TRAMP for file preview and copy/paste because it seems that there are endless amount of synchronous chitchat on just opening a file. Maybe I'm wrong about that. Will the ssh config above solves this issue for you? If not, what's the error message in the preview buffer? |
I will try next time I get the chance. TRAMP does not require any ssh config file though. Shouldn't it be possible to get all this information from Emacs (except maybe the password) and then run If possible, I think it would be better to do things through TRAMP though. It can prompt for the password itself. More importantly, it supports a lot more than just ssh e.g. sudo, docker, and combining different protocols. For example, I used to occasionally pipe ssh to sudo to docker to work inside docker containers on a remote machine (though in this case I was using eshell mostly rather than needing dired). Since dirvish is not using TRAMP, that probably explains why it did not work with a kubernetes pod for @jumper047 (not sure if you can acually ssh into a kubernetes pod or if it works like it does for docker in docker-tramp.el with a separate protocol). I haven't looked at how TRAMP and dired work together by default, so maybe it is just not easily possible to have async file movement this way. If the current implementation is the only way to do it, the documentation should mention it only supports ssh and requires ssh configuration to avoid asking for a password. I will try to get this working sometime next week. Thanks for the explanation. |
This would be a promising solution, but I'm sure if the sub-process have access to the password that is captured by TRAMP, which was the reason I didn't tried this approach. I'll give it a try.
It would be great if we can do these through TRAMP, that's also the spirit of dirvish. I'll see if I can bypass the synchronous part of TRAMP and come with up a better solution than the current ssh one. I've never been able to read through the source code of TRAMP, because I was always intimidated by the intensive usage of regex there 😕 . But I'll try my best.
Definitely. I'll improve the doc on this once I (hopefully) figure out the TRAMP stuff. Thanks for your advice and feedback. |
|
Yes, it probably is the right way to go, I have tried to implement the preview part with this function yesterday and it's working pretty well (although some TRAMP config are required to ensure a usable performance). Since we can use it for preview then I guess we can use it for copy/paste as well. The tricky thing I'm facing now is how to keep as more as features that work locally also works on TRAMP (hopefully we can remove the |
Bad news:
Good news:
|
Thanks for the update.
Is it actually impossible, or is the performance just worse? That heading is titled "Improving performance of asynchronous remote processes." Can't you still use asynchronous processes without
What about over a multi-hop connection? Will they block or just not work?
I don't personally need this.
So file copy/move is still using rsync directly. My main use cases for dired with TRAMP are:
Can rsync work in the second case given that root login is disabled on the remote host? And what will happen with dirvish in the first case? I don't know if it's possible, but it would be nice if dirvish could fall back to using TRAMP with synchronous copy/paste in cases that rsync can't handle or if things aren't configured correctly to allow rsync with ssh. I generally only transfer small files (code) to remote hosts, so synchronous vs. asynchronous is not a huge deal for me. It looks like there's no good way to make everything async, but I'd still like to be able to consistently use the same keybindings everywhere for multi-stage copy/paste if possible.
It looks like this sentence got cut off in the |
Sorry for the confusion. I'm not a TRAMP expert so my understanding can be wrong, but here's what I found:
As I described above, if the connection does not come with the
If I understood this correctly, I think it means "multi-hop connection = always synchronous"
Yes, but it's only used when source files and target are located in different hosts (local-to-or-from-remote, remoteA-remoteB).
In theory, everything works locally should work for in a local sudo connection, I'll make them available on next update if everything goes fine.
I'm not sure but I guess it would work because I found this https://github.com/stsquad/dired-rsync/blob/master/dired-rsync-ert.el#L58, I'll have a look on this.
Good idea. I believe this can be done by the help of tramp and dired-aux. Thanks for this. |
I assume this was how long it took on a remote connection? Did you test with a completely local multi-hop connection? I bring this up because my usage of TRAMP has been mostly connecting to a local mini pc directly over an ethernet cable. In this case, the connection might be much faster. I don't know if it would be fast enough to allow preview to be usable (even a small synchronous delay would be annoying), so the current default behavior makes sense, but if it is a lot faster, it might make sense to let the user opt-in to some features for certain synchronous connections (e.g. local multihop sudo|docker or ssh|sudo for a local pc). Missing preview is not a huge deal in these cases though. I care more about copy/paste. |
Added new option `dirvish-whitelist-host-regex`. If the hostname can be matched by this variable, dirvish tries to use asynchronous process to handle the UI rendering/preview/yank regardless of the `direct-async-process` TRAMP connection property. Preview: support all local connection (including sudo) Yank: use fallback yank/move command when direct async process is not available
Yes.
Nope, because I don't have an available local computer, please help me to test with the case C below. If everything goes fine, the expect behavior would be: How does the preview and copy/paste work on paths like "/ssh:HOST_ON_ETHERNET|sudo:root@servername:/path/"? Not working at all? Performs bad? If it performs badly, will adding HOST_ON_ETHERNET to |
@tdstoff , by 'hangs indefinitely' did you mean it hangs after invoking |
No, actually. I set the following:
and notice that file sizes are then shown like in this screenshot: But within ~10 seconds or so of using the buffer, I'm stuck in a hang that incessant Edit: I reproduced this three times in the same remote directory, then tried accessing the remote host at a different location and it seems to be working at the moment, even |
…luigit#30 alexluigit#34 alexluigit#37) We already have multi-stage and asynchronous copy/paste facilities in Dirvish (`dirvish-yank` command). This commit brings a few new commands that serve for other purposes but have similar mechanism as `dirvish-yank`, they are: - `dirvish-move` - `dirvish-symlink` - `dirvish-relative-symlink` - `dirvish-hardlink` Note that all of them are also asynchronous and work on both localhost and remote host. Former-commit-id: 3837ecf
Former-commit-id: 5da0ec2
Added new option `dirvish-whitelist-host-regex`. If the hostname can be matched by this variable, dirvish tries to use asynchronous process to handle the UI rendering/preview/yank regardless of the `direct-async-process` TRAMP connection property. Preview: support all local connection (including sudo) Yank: use fallback yank/move command when direct async process is not available Former-commit-id: a26ff4b
See: #124 |
Does the above setting Is this setting inherently not compatible with shells? I asked over at the vterm repo here but they seem quite busy. |
Dirvish's file copying mechanics sadly don't work over tramp, while dired default copying/moving works fine.
The text was updated successfully, but these errors were encountered: