I am currently using the following code to hook up flymake and Pyflakes in emacs:
(defun flymake-create-temp-in-system-tempdir (filename prefix)
(make-temp-file (or prefix "flymake")))
and then I pass this function to flymake-init-create-temp-buffer-copy
. (Taken from http://hustoknow.blogspot.com/2010/09/emacs-and-pyflakes-using-tmp-directory.html).
This code worked fine until yesterday. When I visit certain Python files, I get the following error:
switched OFF Flymake mode for buffer admin.py due to fatal status
CFGERR, warning Configuration error has occured while running
(pyflakes ../../../../../../../tmp/flymake28459SVv)
Why is flymake passing what seems like the wrong filename to pyflakes? I expect it to pass something like "/tmp/efe234234" and I haven't modified any of the tmp directory settings.
I don't recall emacs being updated for Ubuntu recently and can't think of anything that might have caused this to mess up (.emacs files are versioned).
The only issue I can think of is that this is a heavily nested directory symlinked to a directory in my ~/Dropbox directory but this doesn't happen to other symlinked in a similar way.
How can I fix this problem?
UPDATE
I've done some debugging and now I see that it's not passing the correct path as the argument. It needs one more parent directory inserted into the path to make it work which makes me think it's getting messed up because of symlinks.
Here is an example shell session to show what I mean. I am doing this from the correct relative directory:
$ pyflakes ../../../../../tmp/flymake13382xHi
../../../../../tmp/flymake13382xHi: No such file or directory
That is the command flymake is trying to run. If I change it:
$ pyflakes ../../../../../../tmp/flymake13382xHi
I get no output (as expected). Note the extra ".." in the path.
How can I get flymake to pass an absolute path instead of these crazy relative paths?
UPDATE 2
I've gotten everything to work. Basically there is this function:
(defun flymake-pyflakes-init ()
; Make sure it's not a remote buffer or flymake would not work
(when (not (subsetp (list (current-buffer)) (tramp-list-remote-buffers)))
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-in-system-tempdir))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "pyflakes" (list temp-file)))))
In the last part I had to change the argument to list
from local-file
to temp-file
because local-file
was the crazy relative path I didn't want. Why did the author of that snippet use local-file
in the first place?
Thanks, Ryan
For me, i have resolved by modify user script /usr/local/bin/pyflakes, i test if file exist, if no, i add a slash.
#!/bin/bash
FILE=$1
# Test if folder exist
if [ ! -e "$FILE" ]; then
FILE="/$1"
fi
epylint "$FILE" 2>/dev/null
pep8 --ignore=E221,E701,E202 --repeat "$FILE"
true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With