2013-05-29 16:25 阅读 74

修复Cygwin Emacs flycheck模式错误在运行xampp php的win7中查找/ tmp和phpcs

Issue with Errors

Have been using Emacs for a couple years. Recently decided to try the Prelude version (link to prelude). Install went smoothly (on Win7 with Cygwin), but have been unable to use php error checking for a couple days. I want to get php error checking to work with Flycheck. It is non-functioning for me right now.

Currently, when I break a php script, flycheck.el (@ln2551) returns 2 errors:

Checker php returned non-zero exit code 1, but no errors from output: 
Could not open input file: /tmp/flycheck4728Btc/myPhpFile.php

Checker definition probably flawed.
Checker php-phpcs returned non-zero exit code 1, but no errors from output:
Could not open input file: /cygdrive/c/xampp/php/phpcs

Checker definition probably flawed.

Debug Info

1). Flycheck writes a buffer copy in Cygwin root /tmp directory. See flycheck.el (@ln800)): This file exists and is a confirmed readable buffer copy; there is no a problem with its file permissions (same error whether chmod 777 or 700).

2). Phpcs is located at c:/xampp/php/phpcs and can be called from the command line (cmd.exe and cygwin bash) with or without the c:/ path; but does not work with the cygdrive path. [This does NOT work $/cydrive/c/xampp/php/phpcs -h (with or without the .bat extension).] I have also confirmed good installation of phpcs (and it works from command line), and that there is not a file permission issue here. I have set the flychech-phpcs-standard variable to c:/xampp/php/phpcs as per flycheck.el @ln2895-2903 but have not found the condition that throws throws the error.

[Note: This error did go away when I tried renaming the phpcs file and specifying the phpcs.bat, but I am not sure sure whether the checker was found or not since the write to tmp file error still thwarted any results. Also, that broke my commandline usage of the phpcs command.]

Just to be sure, here is my php -v:

$ php -v
PHP 5.4.7 (cli) (built: Sep 12 2012 23:48:31)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
    with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans

Here is my phpcs version:

$ phpcs --version
PHP_CodeSniffer version 1.3.3 (stable) by Squiz Pty Ltd. (

And have this alias in my .bash_profile: alias phpcs="c:/xampp/php/phpcs"

And c:\xampp\php on my PATH


I been going through the phpcs, cygwin, and the flycheck.el, including the instructions to customize the flycheck-phpcs-standard lines and have not made any progress on this issue.

I am unsure whether this has something to do with the comments on flycheck.el@800-824 (defun flycheck-temp-file-system (filename prefix) or not. Those are comments about hacking around a compression bug with Emacs. Anyway,

How to fix this?

Any comments or ideas to test this further? Anyone have flycheck working on win7 with Cygwin? Is it an operating systemn compile issue? Directory paths in scripts somewhere?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    dongpang4470 dongpang4470 2013-05-31 17:14

    This is not an error with flycheck!

    [Thanks to the repository owner for giving me a clear answer on that].

    flycheck-phpcs-standard does not take a path to phpcs. I had that wrong. Once I learned that, the context of the documentation made more sense.

    What was happening is that Cygwin environmental path mounting is not what is running when flycheck is used. Phpcs itself is given a unix type path tmp/flycheck23423.buffer-copy and cannot run it. Stink me!

    In response to that new, I was trying to see if I could make windows read those paths. And the good news is you can, ofcourse! This superuser QA was helpful.

    This is how you fix it:

    1) download the windows junction tool to a windows folder from which you will run it in cmd.exe. EDIT: see comment, should use mklink in win7.

    2) C:\your\cmd\path> junction \cygdrive\c \

    ... this will output ...
    Created: C:\cygdrive\c
    Targetted at: C:\

    3) C:\your\cmd\path> junction \tmp C:\cygwin\tmp

    ... this will output ...
    Created: C:\tmp
    Targetted at: C:\cygwin\tmp

    Now, open a php script in emacs and break it. It works! It is phpcs is able to find the /tmp/.. . check it, and return the error messages. Cool.

    点赞 评论 复制链接分享