For context I am looking at a remote file; for example: /ssh:desktop:/home/user/project/src/file.cpp
.
I then issue the interactive command compile
like so:
cd /ssh:desktop:/home/user/project/Release && make
And get the following output:
-*- mode: compilation; default-directory: "/ssh:desktop:/home/user/project/Release/" -*-
Compilation started at Wed May 20 22:42:42
cd /ssh:desktop:/home/user/project/Release && make
/bin/sh: 2: cd: can't cd to /ssh:desktop:/home/user/project/Release
Compilation exited abnormally with code 2 at Wed May 20 22:42:43
Then I tried issuing the interactive command
compile
differently (without the remote prefix):cd /home/user/project/Release && make
And get the following error:
No such directory found via CDPATH environment variable
I can't quite figure it out, but I suspect that the function
cd
(in site-lisp file emacs/lisp/files.el
) has something to do with it:
(defun cd (dir)
"Make DIR become the current buffer's default directory.
If your environment includes a `CDPATH' variable, try each one of
that list of directories (separated by occurrences of
`path-separator') when resolving a relative directory name.
The path separator is colon in GNU and GNU-like systems."
(interactive
(list
;; FIXME: There's a subtle bug in the completion below. Seems linked
;; to a fundamental difficulty of implementing `predicate' correctly.
;; The manifestation is that TAB may list non-directories in the case where
;; those files also correspond to valid directories (if your cd-path is (A/
;; B/) and you have A/a a file and B/a a directory, then both `a' and `a/'
;; will be listed as valid completions).
;; This is because `a' (listed because of A/a) is indeed a valid choice
;; (which will lead to the use of B/a).
(minibuffer-with-setup-hook
(lambda ()
(setq-local minibuffer-completion-table
(apply-partially #'locate-file-completion-table
cd-path nil))
(setq-local minibuffer-completion-predicate
(lambda (dir)
(locate-file dir cd-path nil
(lambda (f) (and (file-directory-p f) 'dir-ok))))))
(unless cd-path
(setq cd-path (or (parse-colon-path (getenv "CDPATH"))
(list "./"))))
(read-directory-name "Change default directory: "
default-directory default-directory
t))))
(unless cd-path
(setq cd-path (or (parse-colon-path (getenv "CDPATH"))
(list "./"))))
(cd-absolute
(or
;; locate-file doesn't support remote file names, so detect them
;; and support them here by hand.
(and (file-remote-p (expand-file-name dir))
(file-accessible-directory-p (expand-file-name dir))
(expand-file-name dir))
(locate-file dir cd-path nil
(lambda (f) (and (file-directory-p f) 'dir-ok)))
(error "No such directory found via CDPATH environment variable"))))