0

I use emacs -Q for reconstruction of the following problem and the output of emacs-version is GNU Emacs 25.1.1 (x86_64-unknown-cygwin, GTK+ Version 3.18.9) of 2016-09-17.

If one tries to complete file-names of files in the root directory "/", e.g. by M-:

(file-name-all-completions "cyg" "/"),

one obtains the error (file-error "Reading directory" "No such file or directory" "/").

I would very much appreciate if someone with a working copy of the last git-version of cygwin-emacs could try to reconstruct this problem and report here whether it is fixed in that version of emacs.

Where can I report this problem? Should I report it directly to http://lists.gnu.org/mailman/listinfo/bug-gnu-emacs or rather to https://cygwin.com/ml/cygwin/?

I am asking because file-name-all-completions is actually a built-in c-function.

My current clumsy workaround is:

(defvar cygwin-root "/cygdrive/c/cygwin64/"
  "Reference of the root directory within /cygpath/...")

(defun cygwin-handle-root-dir (operation &rest args)
  "Several functions don't work for the root-directory \"/\" in cygwin.
We map this directory here to "
  (cond ((eq operation 'file-name-all-completions)
     ;; second arg is the directory "/"
     (when (string-equal (nth 1 args) "/")
       (setf (nth 1 args) cygwin-root)
       )))
    ;; Handle any operation we don’t know about.
  (let ((inhibit-file-name-handlers
     (cons 'cygwin-handle-root-dir
           (and (eq inhibit-file-name-operation operation)
            inhibit-file-name-handlers)))
    (inhibit-file-name-operation operation))
    (apply operation args)))

(add-to-list 'file-name-handler-alist '("^/$" . cygwin-handle-root-dir))
  • Two files you might look into using, if you don't already: cygwin-mount.el, setup-cygwin. – Drew Nov 17 '16 at 16:30
  • I know cygwin-mount.el. I think this package needs a serious update since there are now built-in functions cygwin-convert-file-name-to-windows and cygwin-convert-file-name-from-windows that can partially replace calls to cygpath. The problems that I describe in the question are very low level. Providing a lisp package to circumvent these problems would be a big hack IMHO. – Tobias Nov 17 '16 at 17:57
  • You might be right. But FWIW, I don't have the problem you mention, and I use only those two files. OK, in my case (1) I have an older version of Cygwin, (2) I use an ordinary MS Windows Emacs binary (not from Cygwin), and (3) I used "Cyg", not "cyg", in the test: M-: (file-name-all-completions "Cyg" "/"). That shows ("Cygwin.ico" "Cygwin.bat" "Cygwin-Terminal.ico"). – Drew Nov 17 '16 at 18:07
  • @Drew I think using nt-emacs instead of cygwin-emacs makes a big difference. The call (file-name-all-completions "cyg" "/") should return at least "cygmount". Under cygwin it makes a big difference whether you call commands as cygpath or you use built-in commands. External commands can be extremely slow under cygwin. By the way could you test whether you have the built-in functions cygwin-convert-file-name-to-windows and cygwin-convert-file-name-from-windows? – Tobias Nov 17 '16 at 18:12
  • No, I don't have those functions. Again, my version of Cygwin is not recent. The only function with a similar name that I have is from cygwin-mount.el: cygwin-mount-convert-file-name, which converts, e.g., //x/ to x:/ and /cygdrive/x/ to x:/. – Drew Nov 17 '16 at 18:16
2

Where can I report this problem? Should I report it directly to http://lists.gnu.org/mailman/listinfo/bug-gnu-emacs or rather to https://cygwin.com/ml/cygwin/?

The "true" answer to this depends on where the bug really is. Of course, you don't know where it is yet, so you'll have to guess.

There are a few more things you could do to gather evidence about where the bug lies (ordered by ascending difficulty):

  1. Use (directory-files "/") instead of file-name-all-completions to rule out the completion code being the problem (if it is in fact the completion code, then the bug is almost certainly in Emacs).
  2. Check if the problem exists in earlier versions of Emacs (if no, it suggests the bug is in Emacs)
  3. Check if the problem exists in earlier versions of Cygwin
  4. Try to reproduce the bug in a simple C program that fails to open "/". If you can do this, then you have proved* that the bug is in Cygwin

* Unless there's a mistake in the C program, but since it's small, that should be easy for the Cygwin maintainers to see.


Just going by what you've posted so far, I would suggest reporting an Emacs bug, and if there are no responses in a couple of days, then try sending a message to the Cygwin list pointing to the Emacs bug to see if anyone has some ideas about it.

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.