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 ()
(interactive)
(beginning-of-buffer)
(dired-next-line 2))
(define-key dired-mode-map
(vector 'remap 'beginning-of-buffer) 'dired-back-to-top)
(defun dired-jump-to-bottom ()
(interactive)
(end-of-buffer)
(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."
(interactive)
(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."
(interactive)
(let ((files (dired-get-marked-files)))
(with-temp-buffer
(apply 'call-process "/usr/bin/du" nil t nil "-sch" files)
(message
"Size of all marked files: %s"
(progn
(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
25.0.50.1
(build:ad39858
) on Debian unstable; - I listed (through
C-h m
) the active minor modes both with my init.el and withemacs -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)
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).use-package
declarations fordired+
andbookmark+
.emacs -Q
), Emacs will load any packages you have installed at startup, even if your init-file is empty.