I am trying to copy a file from a remote folder to a directory on my machine. I use Dired, and this the setup related to Dired in my configuration:

(use-package dired
  :bind (("C-c z" . dired-get-size)
         ("C-c C" . copy-file-name-to-clipboard))
  :config (progn
            (setq dired-auto-revert-buffer t ; Revert buffers on revisiting
                  dired-listing-switches "-lFaGh1v --group-directories-first"
                  global-auto-revert-non-file-buffers t ; Auto refresh dired
                  auto-revert-verbose nil ; But be quiet about it
                  dired-dwim-target t ; Use other pane as target when copying
                  dired-recursive-copies 'always ; Copy dirs recursively
                  dired-ls-F-marks-symlinks t ; -F marks links with @
                  dired-guess-shell-alist-user ; Use LibreOffice when needed
                  '(("\\.ods\\'\\|\\.xls?\\'\\|\\.xlsx?\\'" "libreoffice")
                    ("\\.odt\\'\\|\\.doc?\\'\\|\\.docx?\\'" "libreoffice")))

            ;; Make find-name-dired faster
            (use-package find-dired
              :config (setq find-ls-option
                            '("-print0 | xargs -0 ls -ld" . "-ld")))

            ;; Better M-< and M->
            (defun dired-back-to-top ()
              (dired-next-line 2))

            (define-key dired-mode-map
              (vector 'remap 'beginning-of-buffer) 'dired-back-to-top)

            (defun dired-jump-to-bottom ()
              (dired-next-line -1))

            (define-key dired-mode-map
              (vector 'remap 'end-of-buffer) 'dired-jump-to-bottom)

            ;; Open directory with sudo in dired
            (define-key dired-mode-map "!" 'sudired)

            (defun sudired ()
              "Open directory with sudo in dired."
              (use-package tramp)
              (let ((dir (expand-file-name default-directory)))
                (if (string-match "^/sudo:" dir)
                    (user-error "Already in sudo")
                  (dired (concat "/sudo::" dir)))))

            ;; Get files size in dired
            (defun dired-get-size ()
              "Quick and easy way to get file size in dired."
              (let ((files (dired-get-marked-files)))
                  (apply 'call-process "/usr/bin/du" nil t nil "-sch" files)
                   "Size of all marked files: %s"
                     (re-search-backward "\\(^[0-9.,]+[A-Za-z]+\\).*total$")
                     (match-string 1))))))))

(use-package dired-x ; Enable some nice dired features
  :config (progn
            ;; Omit hidden files by default (C-x M-o to show them)
            (setq-default dired-omit-files-p t)
            (setq dired-omit-files (concat dired-omit-files "\\|^\\..+$")
                  dired-omit-verbose nil)))

;; Note: to override dired+ faces, customize `font-lock-maximum-decoration'
;; adding an entry for `dired-mode' and setting decoration to default
(use-package dired+ ; Extend dired
  :ensure t
  :defer 5
  :config (progn
            ;; Reuse buffer for directories
            (diredp-toggle-find-file-reuse-dir 1)
            (setq diredp-hide-details-initially-flag nil
                  diredp-hide-details-propagate-flag nil)))

(use-package bookmark+ ; Better bookmarks
  :ensure t
  :defer 5)

Every time I try to copy from remote to local I get this error:

file-error Setting current directory No such file or directory

This is happening only when I'm copying a file in some nested directory on the remote machine. For instance, if I try to copy /home/admin/bin/foo to my local directory, it works. But if I try to copy /home/admin/bin/foo/bar I get the above mentioned error.

Some extra info:

  • with emacs -Q copying files from remote to local works;
  • with emacs -q I get the same error;
  • copying from local to remote works every time;
  • I am using Emacs (build: ad39858) on Debian unstable;
  • I listed (through C-h m) the active minor modes both with my init.el and with emacs -Q right before starting to copy the remote file: they are the same.

After some debugging, I nailed down the issue to this line of dired-copy-file-recursive:

(copy-file from to ok-flag preserve-time)
  • 1
    Thanks for reporting that the problem does not show up in emacs -Q! At first glance I don't see anything suspicious in your Dired config. Have you tried bisecting your init-file? (Comment out half of it, restart Emacs, see if problem persists. If it does, offending code is in portion that's not commented out and vice versa. Comment out half of the code that's causing the error. Rinse and repeat until only a few lines remain uncommented.) In this case I'd probably start by commenting out everything but the Dired-related customizations (to check whether your Dired setup really is to blame). – itsjeyd May 7 '15 at 12:40
  • Thank you. I did comment out almost everything, leaving only use-package and Dired configuration. Same error. – Manuel Uberti May 7 '15 at 12:45
  • OK, that means you can leave everything commented out and continue bisecting your Dired config. Shouldn't take more than a few iterations to narrow the problem down. I'd probably start by commenting out the use-package declarations for dired+ and bookmark+. – itsjeyd May 7 '15 at 12:56
  • Actually, I created a new, empty init.el and started Emacs with that instead of mine. I'm still getting the error. – Manuel Uberti May 7 '15 at 13:02
  • 2
    Sounds like one of your add-on packages is to blame. Unless you tell it not to (e.g. via emacs -Q), Emacs will load any packages you have installed at startup, even if your init-file is empty. – itsjeyd May 7 '15 at 13:13

To solve this issue I opened a bug on the bug tracker, and finally a fix was found.

Checking with M-x list-load-path-shadows, I found out that tramp* files in /usr/local/share/emacs/site-lisp/ were hiding the correct tramp* files. Just removing them fixed this issue once and for all.

Thanks to Michael Albinus, then. I'll leave a link to the bug tracker if anyone is interested in the details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.