Alexander-Miller / treemacs

GNU General Public License v3.0
2.1k stars 154 forks source link

Remote tramp connections not working after Emacs restart #929

Closed Chadnelson31 closed 1 year ago

Chadnelson31 commented 2 years ago

I have a couple remote directories added as projects in my treemacs workspace. I am also currently using a mix of auth-sources and pass to store credentials for my connections. When I setup the remote path as a project, the credentials are decrypted correctly and I am able to access the files, but after I restart emacs and load my workspace the connection fails. I confirmed that this behavior only happens with saved workspaces in treemacs, as connecting over tramp alone using the pass credentials works fine across restarts.

Alexander-Miller commented 2 years ago

This one needs debugging. Run (treemacs-current-workspace) in both scenarios, with tramp just set up and woring, and after a restart and not working, and tell me what the project looks like.

You need the part of the output that looks like this: #s(treemacs-project "Treemacs" "/home/am/Documents/git/treemacs" local-readable nil)

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity.

zoechi commented 1 year ago

I just run into the same issue. I set up the workspace with a reference like

* DevOps
  * My Server
    - path :: /ssh:myserver|sudo:myserver:/opt/projects

Accepting with C-c C-c and it works beautifully.

After closing and restarting Emacs the configuration looks like

* DevOps
  * My Server
    - path :: /sudo:root@myserver:/opt/projects

and of course I can't connect anymore. I have to change it to above path to make it work again.

Alexander-Miller commented 1 year ago

Problem should be fixed now - that strange transformation happens when calling abbreviate-file-name on a remote path. Treemacs will stop doing that for any paths starting with "/ssh:". Let me know if there's any other patterns I should exclude.

jidicula commented 5 months ago

Let me know if there's any other patterns I should exclude.

@Alexander-Miller you might want to include every name in the tramp-methods alist. Names are basically the prefixes for paths, e.g. ssh gets turned into /ssh:. This is what my tramp-methods looks like at the moment:

(("ghcs" (tramp-login-program "gh")
  (tramp-login-args (("codespace") ("ssh") ("-c") ("%h")))
  (tramp-remote-shell "/bin/sh") (tramp-remote-shell-login ("-l"))
  (tramp-remote-shell-args ("-c")))
 ("adb" (tramp-login-program "adb") (tramp-login-args (("-s" "%d") ("shell")))
  (tramp-direct-async t) (tramp-tmpdir "/data/local/tmp")
  (tramp-default-port 5555))
 ("kubernetes" (tramp-login-program "kubectl")
  (tramp-login-args (("exec") ("%h") ("-it") ("--") ("%l")))
  (tramp-config-check tramp-kubernetes--current-context-data)
  (tramp-direct-async (#1="/bin/sh" "-c")) (tramp-remote-shell #1#)
  (tramp-remote-shell-login ("-l")) (tramp-remote-shell-args ("-i" "-c")))
 ("podman" (tramp-login-program "podman")
  (tramp-login-args (("exec") ("-it") ("-u" "%u") ("%h") ("%l")))
  (tramp-direct-async (#1# "-c")) (tramp-remote-shell #1#)
  (tramp-remote-shell-login ("-l")) (tramp-remote-shell-args ("-i" "-c")))
 ("docker" (tramp-login-program "docker")
  (tramp-login-args (("exec") ("-it") ("-u" "%u") ("%h") ("%l")))
  (tramp-direct-async (#1# "-c")) (tramp-remote-shell #1#)
  (tramp-remote-shell-login ("-l")) (tramp-remote-shell-args ("-i" "-c")))
 ("ftp")
 ("rclone"
  (tramp-mount-args ("--no-unicode-normalization" "--dir-cache-time" "0s"))
  (tramp-copyto-args nil) (tramp-moveto-args nil) (tramp-about-args ("--full")))
 ("fcp" (tramp-login-program "fsh")
  (tramp-login-args (("%h") ("-l" "%u") ("sh" "-i"))) (tramp-remote-shell #1#)
  (tramp-remote-shell-login ("-l")) (tramp-remote-shell-args ("-i") ("-c"))
  (tramp-copy-program "fcp") (tramp-copy-args (("-p" "%k")))
  (tramp-copy-keep-date t))
 ("psftp" (tramp-login-program "plink")
  (tramp-login-args
   (("-l" "%u") ("-P" "%p") ("-ssh") ("-t") ("%h") ("\"")
    ("env 'TERM=dumb' 'PROMPT_COMMAND=' 'PS1=#$ '") ("%l") ("\"")))
  (tramp-remote-shell #1#) (tramp-remote-shell-login ("-l"))
  (tramp-remote-shell-args ("-c")) (tramp-copy-program "pscp")
  (tramp-copy-args (("-l" "%u") ("-P" "%p") ("-sftp") ("-p" "%k") ("-q")))
  (tramp-copy-keep-date t))
 ("pscp" (tramp-login-program "plink")
  (tramp-login-args
   (("-l" "%u") ("-P" "%p") ("-ssh") ("-t") ("%h") ("\"")
    ("env 'TERM=dumb' 'PROMPT_COMMAND=' 'PS1=#$ '") ("%l") ("\"")))
  (tramp-remote-shell #1#) (tramp-remote-shell-login ("-l"))
  (tramp-remote-shell-args ("-c")) (tramp-copy-program "pscp")
  (tramp-copy-args (("-l" "%u") ("-P" "%p") ("-scp") ("-p" "%k") ("-q") ("-r")))
  (tramp-copy-keep-date t) (tramp-copy-recursive t))
 ("plinkx" (tramp-login-program "plink")
  (tramp-login-args
   (("-load") ("%h") ("-t") ("\"")
    ("env 'TERM=dumb' 'PROMPT_COMMAND=' 'PS1=#$ '") ("%l") ("\"")))
  (tramp-remote-shell #1#) (tramp-remote-shell-login ("-l"))
  (tramp-remote-shell-args ("-c")))
 ("plink" (tramp-login-program "plink")
  (tramp-login-args
   (("-l" "%u") ("-P" "%p") ("-ssh") ("-t") ("%h") ("\"")
    ("env 'TERM=dumb' 'PROMPT_COMMAND=' 'PS1=#$ '") ("%l") ("\"")))
  (tramp-remote-shell #1#) (tramp-remote-shell-login ("-l"))
  (tramp-remote-shell-args ("-c")))
 ("krlogin" (tramp-login-program "krlogin")
  (tramp-login-args (("%h") ("-l" "%u") ("-x"))) (tramp-remote-shell #1#)
  (tramp-remote-shell-login ("-l")) (tramp-remote-shell-args ("-c")))
 ("ksu" (tramp-login-program "ksu") (tramp-login-args (("%u") ("-q")))
  (tramp-remote-shell #1#) (tramp-remote-shell-login ("-l"))
  (tramp-remote-shell-args ("-c")) (tramp-connection-timeout 10))
 ("doas" (tramp-login-program "doas") (tramp-login-args (("-u" "%u") ("-s")))
  (tramp-remote-shell #1#) (tramp-remote-shell-args ("-c"))
  (tramp-connection-timeout 10) (tramp-session-timeout 300)
  (tramp-password-previous-hop t))
 ("sudo" (tramp-login-program "env")
  (tramp-login-args
   (("SUDO_PROMPT=P\"\"a\"\"s\"\"s\"\"w\"\"o\"\"r\"\"d\"\":") ("sudo")
    ("-u" "%u") ("-s") ("-H") ("%l")))
  (tramp-remote-shell #1#) (tramp-remote-shell-login ("-l"))
  (tramp-remote-shell-args ("-c")) (tramp-connection-timeout 10)
  (tramp-session-timeout 300) (tramp-password-previous-hop t))
 ("sg" (tramp-login-program "sg") (tramp-login-args (("-") ("%u")))
  (tramp-remote-shell #1#) (tramp-remote-shell-args ("-c"))
  (tramp-connection-timeout 10))
 ("su" (tramp-login-program "su") (tramp-login-args (("-") ("%u")))
  (tramp-remote-shell #1#) (tramp-remote-shell-login ("-l"))
  (tramp-remote-shell-args ("-c")) (tramp-connection-timeout 10))
 ("nc" (tramp-login-program "telnet") (tramp-login-args (("%h") ("%p") ("%n")))
  (tramp-remote-shell #1#) (tramp-remote-shell-login ("-l"))
  (tramp-remote-shell-args ("-c")) (tramp-copy-program "nc")
  (tramp-copy-args (("-w" "1") ("-v") ("%h") ("%r")))
  (tramp-remote-copy-program "nc")
  (tramp-remote-copy-args (("-l") ("-p" "%r") ("%n"))))
 ("telnet" (tramp-login-program "telnet")
  (tramp-login-args (("%h") ("%p") ("%n"))) (tramp-remote-shell #1#)
  (tramp-remote-shell-login ("-l")) (tramp-remote-shell-args ("-c")))
 ("sshx" (tramp-login-program "ssh")
  (tramp-login-args
   (("-l" "%u") ("-p" "%p") ("%c") ("-e" "none") ("-t" "-t")
    ("-o" "RemoteCommand=\"%l\"") ("%h")))
  (tramp-async-args (("-q"))) (tramp-remote-shell #1#)
  (tramp-remote-shell-login ("-l")) (tramp-remote-shell-args ("-c")))
 ("ssh" (tramp-login-program "ssh")
  (tramp-login-args (("-l" "%u") ("-p" "%p") ("%c") ("-e" "none") ("%h")))
  (tramp-async-args (("-q"))) (tramp-direct-async t) (tramp-remote-shell #1#)
  (tramp-remote-shell-login ("-l")) (tramp-remote-shell-args ("-c")))
 ("remsh" (tramp-login-program "remsh") (tramp-login-args (("%h") ("-l" "%u")))
  (tramp-remote-shell #1#) (tramp-remote-shell-login ("-l"))
  (tramp-remote-shell-args ("-c")))
 ("rsh" (tramp-login-program "rsh") (tramp-login-args (("%h") ("-l" "%u")))
  (tramp-remote-shell #1#) (tramp-remote-shell-login ("-l"))
  (tramp-remote-shell-args ("-c")))
 ("rsync" (tramp-login-program "ssh")
  (tramp-login-args (("-l" "%u") ("-p" "%p") ("%c") ("-e" "none") ("%h")))
  (tramp-async-args (("-q"))) (tramp-direct-async t) (tramp-remote-shell #1#)
  (tramp-remote-shell-login ("-l")) (tramp-remote-shell-args ("-c"))
  (tramp-copy-program "rsync")
  (tramp-copy-args (("-t" "%k") ("-p") ("-r") ("-s") ("-c")))
  (tramp-copy-env (("RSYNC_RSH") ("ssh") ("%c"))) (tramp-copy-keep-date t)
  (tramp-copy-keep-tmpfile t) (tramp-copy-recursive t))
 ("scpx" (tramp-login-program "ssh")
  (tramp-login-args
   (("-l" "%u") ("-p" "%p") ("%c") ("-e" "none") ("-t" "-t")
    ("-o" "RemoteCommand=\"%l\"") ("%h")))
  (tramp-async-args (("-q"))) (tramp-remote-shell #1#)
  (tramp-remote-shell-login ("-l")) (tramp-remote-shell-args ("-c"))
  (tramp-copy-program "scp")
  (tramp-copy-args
   (("-P" "%p") ("-p" "%k") ("%x") ("%y") ("%z") ("-q") ("-r") ("%c")))
  (tramp-copy-keep-date t) (tramp-copy-recursive t))
 ("scp" (tramp-login-program "ssh")
  (tramp-login-args (("-l" "%u") ("-p" "%p") ("%c") ("-e" "none") ("%h")))
  (tramp-async-args (("-q"))) (tramp-direct-async t) (tramp-remote-shell #1#)
  (tramp-remote-shell-login ("-l")) (tramp-remote-shell-args ("-c"))
  (tramp-copy-program "scp")
  (tramp-copy-args
   (("-P" "%p") ("-p" "%k") ("%x") ("%y") ("%z") ("-q") ("-r") ("%c")))
  (tramp-copy-keep-date t) (tramp-copy-recursive t))
 ("remcp" (tramp-login-program "remsh") (tramp-login-args (("%h") ("-l" "%u")))
  (tramp-remote-shell #1#) (tramp-remote-shell-login ("-l"))
  (tramp-remote-shell-args ("-c")) (tramp-copy-program "rcp")
  (tramp-copy-args (("-p" "%k"))) (tramp-copy-keep-date t))
 ("rcp" (tramp-login-program "rsh") (tramp-login-args (("%h") ("-l" "%u")))
  (tramp-remote-shell #1#) (tramp-remote-shell-login ("-l"))
  (tramp-remote-shell-args ("-c")) (tramp-copy-program "rcp")
  (tramp-copy-args (("-p" "%k") ("-r"))) (tramp-copy-keep-date t)
  (tramp-copy-recursive t))
 ("smb" (tramp-tmpdir "/C$/Temp") (tramp-case-insensitive t))
 ("sshfs"
  (tramp-mount-args
   (("-C") ("-p" "%p") ("-o" "dir_cache=no") ("-o" "transform_symlinks")
    ("-o" "idmap=user,reconnect")))
  (tramp-login-program "ssh")
  (tramp-login-args
   (("-q") ("-l" "%u") ("-p" "%p") ("-e" "none") ("%a" "%a") ("%h") ("%l")))
  (tramp-direct-async t) (tramp-remote-shell #1#)
  (tramp-remote-shell-login ("-l")) (tramp-remote-shell-args ("-c")))
 ("sudoedit"
  (tramp-sudo-login
   (("sudo") ("-u" "%u") ("-S") ("-H") ("-p" "Password:") ("--")))
  (tramp-password-previous-hop t))
 ("-"))
Alexander-Miller commented 5 months ago

you might want to include every name in the tramp-methods alist.

Done :+1: