emacs-flymake icon indicating copy to clipboard operation
emacs-flymake copied to clipboard

"Configuration error..." when using on files opened from symbolic link directories

Open Gilwyad opened this issue 10 years ago • 3 comments

Consider the following scenario:

~/projects/name/test.pl ~/shortcut -> ~/projects/name

If I open test.pl from projects/name, flymake works. However if I open it through the symbolic link "shortcut" then I get a "configuration error has occured... flymake will be switched off". Analyzing the log file, the problem is the temporary copy test_flymake.pl was not found! It was created correctly however:

[2013-08-17 11:33:07.549462] starting process on dir /home/peter/shortcut/
[2013-08-17 11:33:07.558302] started process 20470, command=(perl -wc ../projects/name/test_flymake.pl)
[2013-08-17 11:33:07.584354] received 85 byte(s) of output from process 20470
[2013-08-17 11:33:07.592350] received process output: 
  > Can't open perl script "../projects/name/test_flymake.pl": No such file or directory
  > 

At first look it seems the path is correct, but there is a problem. On Debian linux in bash, if I'm in a symbolic link that's pointing to a directory, cd .. takes me out of the "symbolic directory" (to where the symbolic link is), but executing a file with .. does not behave the same: it refers to the directory one level above the linked directory, NOT the symbolic link itself!

peter@atom:~$ ls -l
total 12
-rw-r--r-- 1 peter peter 4758 Aug 17 11:35 flymake.log
drwxr-xr-x 3 peter peter 4096 Aug 17 11:25 projects
lrwxrwxrwx 1 peter peter   25 Aug 17 11:27 shortcut -> /home/peter/projects/name

peter@atom:~/shortcut$ cd ..
peter@atom:~$ 
peter@atom:~$ cd shortcut
peter@atom:~/shortcut$ ls ..
name

I would have too, expected ls .. to list the home directory, but it lists ~/projects instead, that's why the file is not found!

Gilwyad avatar Aug 17 '13 19:08 Gilwyad

I have the exact same problem, and it's really annoying. Anything new on this one?

ramnes avatar Jun 19 '14 10:06 ramnes

After investigation, it seems that the problem came from my flymake + pyflakes init snippet. See https://github.com/ramnes/.emacs.d/commit/d47e2004739b780f7424a261fe195e6dadc33def.

ramnes avatar Jun 19 '14 10:06 ramnes

Right, but still, there is a lot of Emacs code out there (including inside flymake.el) that still calls file-relative-name in a way that exhibits this issue. Here is a workaround:

(defun with-noop-file-relative-name
    (orig &rest init-args)
  "Ensures that `file-relative-name' does nothing while calling ORIG."
  (cl-letf (((symbol-function 'file-relative-name)
             (lambda (orig-name &rest ignores) orig-name)))
    (apply orig init-args)))

And then, advise every function such as php-flymake-php-init that relies internally on file-relative-name:

(eval-after-load "php-mode"
    '(add-function :around (symbol-function 'php-flymake-php-init)
                   #'with-noop-file-relative-name))

domq avatar Jul 09 '18 11:07 domq