php - arc lint 命令失败并出现错误 #1

标签 php python pylint phabricator arcanist

我已经配置了arc lint使用pylint通过在 .arclint 文件中定义 linter:

{
  "linters": {
    "pylint": {
      "type": "pylint",
      "include": "(\\.py$)"
    }
  }
}

在任何 *.py 上执行 arc lint 命令后,我收到下一个异常:

[2016-07-12 14:18:10] EXCEPTION: (PhutilAggregateException) Some linters failed:
- CommandException: Command failed with error #1!
  COMMAND
  'pylint' '--reports=no' '--msg-template={line}|{column}|{msg_id}|{symbol}|{msg}' '/Users/aivaneyko/Projects/raw/module/file.py'

  STDOUT
  ************* Module module.file


  STDERR
  Traceback (most recent call last):
    File "/Users/aivaneyko/Projects/raw/env/bin/pylint", line 11, in <module>
      sys.exit(run_pylint())
    File "/Users/aivaneyko/Projects/raw/env/lib/python2.7/site-packages/pylint/__init__.py", line 23, in run_pylint
      Run(sys.argv[1:])
    File "/Users/aivaneyko/Projects/raw/env/lib/python2.7/site-packages/pylint/lint.py", line 1315, in __init__
      linter.check(args)
    File "/Users/aivaneyko/Projects/raw/env/lib/python2.7/site-packages/pylint/lint.py", line 736, in check
      self._do_check(files_or_modules)
    File "/Users/aivaneyko/Projects/raw/env/lib/python2.7/site-packages/pylint/lint.py", line 867, in _do_check
      self.check_astroid_module(ast_node, walker, rawcheckers, tokencheckers)
    File "/Users/aivaneyko/Projects/raw/env/lib/python2.7/site-packages/pylint/lint.py", line 947, in check_astroid_module
      walker.walk(ast_node)
    File "/Users/aivaneyko/Projects/raw/env/lib/python2.7/site-packages/pylint/utils.py", line 938, in walk
      self.wa... (1,689 more bytes) ... at [<arcanist>/src/lint/engine/ArcanistLintEngine.php:274]
arcanist(head=master, ref.master=4d4d16f25985), phutil(head=master, ref.master=32c56dc20b39)
  #0 <#2> ExecFuture::resolvex() called at [<arcanist>/src/lint/linter/ArcanistExternalLinter.php:448]
  #1 <#2> ArcanistExternalLinter::resolveFuture(string, ExecFuture) called at [<arcanist>/src/lint/linter/ArcanistFutureLinter.php:34]
  #2 <#2> ArcanistFutureLinter::didLintPaths(array) called at [<arcanist>/src/lint/engine/ArcanistLintEngine.php:594]
  #3 <#2> ArcanistLintEngine::executeDidLintOnPaths(ArcanistPyLintLinter, array) called at [<arcanist>/src/lint/engine/ArcanistLintEngine.php:545]
  #4 <#2> ArcanistLintEngine::executeLintersOnChunk(array, array) called at [<arcanist>/src/lint/engine/ArcanistLintEngine.php:473]
  #5 <#2> ArcanistLintEngine::executeLinters(array) called at [<arcanist>/src/lint/engine/ArcanistLintEngine.php:216]
  #6 ArcanistLintEngine::run() called at [<arcanist>/src/workflow/ArcanistLintWorkflow.php:334]
  #7 ArcanistLintWorkflow::run() called at [<arcanist>/scripts/arcanist.php:394]

我的arc --version输出:

arcanist 4d4d16f25985f133501f20fdddd183e525f00341 (28 Jun 2016)

libphutil 32c56dc20b39cffd0cfef931f6f4ab9c99f12677 (7 Jul 2016)

我的pylint --version输出:

pylint 1.5.6, astroid 1.4.7 Python 2.7.10 (default, Oct 23 2015, 19:19:21) [GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)]

我在 PHP 5.5.34 上遇到异常,升级到 PHP 5.6.23 后问题仍然存在。另外,我尝试安装其他版本的arcanist,但没有成功 - arcanist 57f6fb59d73994d90cd94143787424ce0fdbf73b (2016年1月25日)libphutil f43291e99d36045bc459e5133454c0d8fd8768ea (1月21日) 2016)

操作系统:El Capitan 10.11.5

最佳答案

就我而言,问题与ValueError:未知区域设置:UTF-8有关。

如果您在 MacOS 上遇到相同的错误,这里是快速修复(在 bash 中导出):

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

如何修复:

请使用“test.php”脚本重现问题(提供文件路径而不是“文件路径/文件”):

<?php
$descriptorspec = array(
    0 => array("pipe", "r"),
    1 => array("pipe", "w"),
    2 => array("file", "error_output.txt", "a")
);
$process = proc_open('"pylint" "--reports=no" "--msg-template={line}|{column}|{msg_id}|{symbol}|{msg}"   "path-to-file/file"', $descriptorspec, $pipes);
if (is_resource($process)) {
    fclose($pipes[0]);
    echo stream_get_contents($pipes[1]);
    fclose($pipes[1]);
    $return_value = proc_close($process);
    echo "command returned $return_value\n";
}
?>

您可以检查“error_output.txt”文件中是否存在错误。

祝你好运! :)

关于php - arc lint 命令失败并出现错误 #1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38331830/

相关文章:

Python - 通过引用复制

python - 有条件地创建(填充)一列,该列必须处理数据框中的行以匹配条件

使用ajax的php-mysql登录系统

python 从日期时间对象获取时区值

python - 将常量从外部文件导入到 python 中

python - pylint 在 PyQt4 中找不到 QtCore

python - 如何在 Visual Studio Code 中修改 pylint 的变量命名约定

php - Doctrine 复杂内连接

php - PHP中下个月日期时间戳的最后一天?

php - Stripe 创建退款不起作用