In flymake-proc.el:
(defun flymake-proc--delete-temp-directory (dir-name)
"Attempt to delete temp dir created by `flymake-proc-create-temp-with-folder-structure', do not fail on error."
(let* ((temp-dir temporary-file-directory)
(suffix (substring dir-name (1+ (length (directory-file-name temp-dir))))))
(while (> (length suffix) 0)
(setq suffix (directory-file-name suffix))
;;+(flymake-log 0 "suffix=%s" suffix)
(flymake-proc--safe-delete-directory
(file-truename (expand-file-name suffix temp-dir)))
(setq suffix (file-name-directory suffix)))))
Line 901 should be
(let* ((temp-dir (file-truename temporary-file-directory))
This is because the default value of variable temporary-file-directory might be abbreviated, so substring does not work correctly. For example, on my system (Windows) the default value is "c:/Users/HECTOR~1/AppData/Local/Temp/". It ended up trying to delete my source directory (!), but fortunately permission is denied.
A workaround is to manually set temporary-file-directory in .emacs to the correct full path.
Regards,
Hon