Doom-emacs: [BUG] Remote/TRAMP dired not listing files

Created on 23 Aug 2019  Â·  14Comments  Â·  Source: hlissner/doom-emacs

Remote/TRAMP dired not listing files

A plain vanilla Emacs 27 will list remote files in dired mode if with TRAMP you choose a directory instead of a file. A fresh install of Doom Emacs with only evil uninstalled will not. I can find no errors in Messages or in TRAMP buffers. Weirdly I was able to make it work once or twice, but even that stopped happening. Tab completion of file names while navigating in the minibuffer works, however. I should also note the remote server is FreeBSD 11 and 12 (I tried both) and shell is zsh

Plain
image

Doom
image

Steps to reproduce

  1. C-x C-f and open remote, e.g. /ssh:host:/usr/local/etc/nginx/
  2. Frown when files are not listed as expected
  3. Hit g to refresh listing
  4. Repeat #2

System information

  • OS: darwin (x86_64-apple-darwin19.0.0)
  • Shell: /usr/local/bin/zsh
  • Emacs: 27.0.50 (Aug 07, 2019)
  • Doom: 2.0.9 (HEAD -> develop, origin/develop, origin/HEAD f754d4ff 2019-07-23 18:23:17 +0200)
  • Graphic display: t (daemon: nil)
  • System features: RSVG IMAGEMAGICK GLIB NOTIFY KQUEUE ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS MODULES THREADS JSON PDUMPER LCMS2 GMP
  • Details:
    elisp env bootstrapper: envvar-file elc count: 0 uname -a: Darwin 19.0.0 Darwin Kernel Version 19.0.0: Fri Aug 9 21:59:46 PDT 2019; root:xnu-6153.0.139.161.2~2/RELEASE_X86_64 x86_64 modules: (:completion company ivy :ui doom doom-dashboard doom-quit hl-todo modeline nav-flash ophints (popup +all +defaults) treemacs vc-gutter vi-tilde-fringe window-select workspaces :editor file-templates fold multiple-cursors rotate-text snippets :emacs dired electric vc :tools eval flycheck (lookup +docsets) magit :lang data emacs-lisp markdown (org +dragndrop +ipython +pandoc +present) sh :config default) packages: n/a exec-path: (~/.local/bin ~/.cargo/bin ~/.cask/bin ~/.fastlane/bin ~/go/bin /usr/local/bin /usr/local/go/bin /usr/local/opt/mysql-client/bin /usr/local/opt/[email protected]/bin /usr/local/opt/[email protected]/sbin /usr/local/opt/python/libexec/bin /usr/local/opt/sqlite/bin /usr/local/sbin /bin /sbin /usr/bin /usr/sbin ~/.local/bin ~/go/bin ~/.cask/bin ~/.fastlane/bin ~/.cargo/bin /Library/TeX/texbin /usr/local/opt/[email protected]/bin /usr/local/opt/[email protected]/sbin /usr/local/opt/[email protected]/bin /usr/local/opt/python@2/bin /usr/local/go/bin /usr/local/bin /usr/local/sbin ~/.cargo/bin /usr/local/bin /usr/bin /bin /usr/sbin /sbin /Library/Apple/usr/bin /Library/Apple/bin /usr/local/MacGPG2/bin /usr/local/share/dotnet ~/.dotnet/tools ~/.local/bin ~/go/bin ~/.cask/bin ~/.fastlane/bin ~/.cargo/bin /Library/TeX/texbin /usr/local/opt/[email protected]/bin /usr/local/opt/[email protected]/sbin /usr/local/opt/[email protected]/bin /usr/local/opt/python@2/bin /usr/local/go/bin /usr/local/sbin /usr/local/opt/mysql-client/bin /usr/local/opt/[email protected]/bin /usr/local/opt/[email protected]/sbin /usr/local/opt/python/libexec/bin /usr/local/opt/sqlite/bin /usr/local/Cellar/emacs-plus/HEAD-d5622eb/libexec/emacs/27.0.50/x86_64-apple-darwin19.0.0/)
:emacs dired bug remote resolved

Most helpful comment

No, sorry :( Here's the output:

Tramp: Opening connection for prodr using ssh...
Tramp: Sending command ‘exec ssh   -o ControlMaster=auto -o ControlPath='tramp.%C' -o ControlPersist=no -e none prodr’
Tramp: Waiting for prompts from remote shell...done
Tramp: Found remote shell prompt on ‘prodr’
Tramp: Opening connection for prodr using ssh...done
Opening directory /ssh:prodr:/usr/local/etc/...failed
ls-lisp-format: Format specifier doesn’t match argument type
Mark set

This however still works in the newest updates:

(add-hook 'dired-mode-hook
          (lambda ()
            (when (file-remote-p dired-directory)
              (setq-local dired-actual-switches "-alhB"))))

All 14 comments

It appears the Doom dired package is the culprit

Does dired emit any warnings or error messages in *Messages* when you open the remote? (This buffer can be accessed via C-h e or M-x view-echo-area-messages)

I only see this:

Tramp: Opening connection for superset using ssh...
Tramp: Sending command ‘exec ssh -o ControlMaster=auto -o ControlPath='tramp.%C' -o ControlPersist=no -e none superset’
Tramp: Waiting for prompts from remote shell...done
Tramp: Found remote shell prompt on ‘superset’
Tramp: Opening connection for superset using ssh...done

OK, dug around a bit more and it turns out dired-listing-switches is still set to "-aBhl --group-directories-first" when the remote system is FreeBSD. Applying this patch made dired work correctly for me on my FreeBSD servers:

diff --git a/modules/emacs/dired/config.el b/modules/emacs/dired/config.el
index aac74ea0..b6a49ee8 100755
--- a/modules/emacs/dired/config.el
+++ b/modules/emacs/dired/config.el
@@ -24,7 +24,8 @@
           (setq insert-directory-program gls)
         ;; BSD ls doesn't support --group-directories-first
         (setq args (delete "--group-directories-first" args))))
-    (setq dired-listing-switches (string-join args " ")))
+    ;; (setq dired-listing-switches (string-join args " "))
+    )

   (define-key! dired-mode-map
     ;; Kill buffer when quitting dired buffers

Since I don't want to be patching the core Doom package, I reverted and added this hook from here in my .doom.d/config.el and so far it's working OK:

(add-hook 'dired-mode-hook
(lambda ()
(when (file-remote-p dired-directory)
  (setq-local dired-actual-switches "-alhB"))))

Does this work for you?

  (add-hook! 'dired-mode-hook
    (when (file-remote-p dired-directory)
      (setq ls-lisp-use-insert-directory-program nil)))

No, sorry :( Here's the output:

Tramp: Opening connection for prodr using ssh...
Tramp: Sending command ‘exec ssh   -o ControlMaster=auto -o ControlPath='tramp.%C' -o ControlPersist=no -e none prodr’
Tramp: Waiting for prompts from remote shell...done
Tramp: Found remote shell prompt on ‘prodr’
Tramp: Opening connection for prodr using ssh...done
Opening directory /ssh:prodr:/usr/local/etc/...failed
ls-lisp-format: Format specifier doesn’t match argument type
Mark set

This however still works in the newest updates:

(add-hook 'dired-mode-hook
          (lambda ()
            (when (file-remote-p dired-directory)
              (setq-local dired-actual-switches "-alhB"))))

Sorry for the late followup. Does this work for you?

  (add-hook! 'dired-mode-hook
    (defun +dired-disable-gnu-ls-flags-in-tramp-buffers-h ()
      (when (file-remote-p dired-directory)
        (setq-local dired-listing-switches
                    (string-join
                     (split-string dired-listing-switches
                                   "--group-directories-first")
                     " ")))))

EDIT: It appears to work for me, but I'd like to hear how it fares for you before I close the issue.

EDIT: It appears to work for me, but I'd like to hear how it fares for you before I close the issue.

Tested for me (Ubuntu 18.04 with remote dir on CentOS) but it doesn't work.

However, @scaba workaround fix the problem for me.

@hlissner - Similar to @tchabaud and @scaba above, the fix doesn't work for me on MacOS, but the @scaba workaround does. Would you consider re-opening the bug ?

As of bd64056 I've implemented @scaba's workaround. Let me know if that isn't the case and I'll reopen it. Thanks for bringing it to my attention!

@hlissner - Thanks for tackling this!

This didn't wind up working for me on Mac OS X, except in one case. If I enabled Minimal Ranger Mode (Deer) - this worked. If I didn't, I got the same result. That was true with just (dired) and (dired +icons).

Went back to @scaba workaround in the config file for now.

@jonathanwilner Which one? The fix I implemented _was_ scaba's workaround...

Could you check the value of dired-listing-switches (SPC h v dired-listing-switches), perhaps something (maybe ranger or your own config) is changing the value elsewhere?

I ended up here after tracking down an issue I had using the new tramp-rclone backend. I was able to fix it by editing +dired-disable-gnu-ls-flags-in-tramp-buffers-h to set dired-actual-switches instead of dired-listing-switches, which I think is the difference between your fix and @scaba's workaround.

@ajgrf Gotcha. I pushed the fix in bc0db09, so this issue can finally be put to rest.

Was this page helpful?
0 / 5 - 0 ratings