"ctags: Unknown option: --output-format" 错误

"ctags: Unknown option: --output-format" error

在 macOS 上,运行 此命令出现错误:

ctags -R --output-format=json --languages=ruby --exclude=.git --exclude=log . $(bundle list --paths) -f .tags

根据此处的建议:https://www.boost.co.nz/blog/2018/01/improving-ruby-rails-debugging-ctags

这似乎是一个有效的命令选项:https://docs.ctags.io/en/latest/output-format.html

所以我不确定为什么会收到错误消息。

更新: 好的,那篇博客文章从 HEAD 公式安装了 ctags。所以我安装了那个版本,但现在我得到了一个不同的错误:

ctags: unknown output format name supplied for "output-format=json"

只有在使用 libjansson 库构建 ctags 可执行文件时才能使用 json 输出。

如果您使用 libjansson 构建了 ctags 可执行文件,您将在 --list-features 输出中看到 "json",如:

$ universal-ctags --list-features
#NAME             DESCRIPTION
iconv             can convert input/output encodings
interactive       accepts source code from stdin
json              supports json format output
...

如果您没有找到 "json",您必须使用 libjansson 库重建 ctags 可执行文件。 如果找到 "json",但选项 --output-format=json 不起作用,这将是一个错误。我建议您向 https://github.com/universal-ctags/ctags/issues 报告它,但我们不承诺修复它。

我看了同一篇文章,得到了同样的错误。问题是建议的命令:

brew install --HEAD universal-ctags/universal-ctags/universal-ctags

这不会用 libjansson 构建 universal-ctags,正如 Masatake YAMATO 所建议的那样,需要 libjansson 才能使用 --output-format=json

尝试使用 --with-jansson 标志安装 universal-ctags

brew install --HEAD --with-jansson universal-ctags/universal-ctags/universal-ctags

此外,为避免 ctags: -f option may not follow a file name 错误,将 -f .tags 移到 . $(bundle list --paths) 之前:

ctags -R --output-format=json --languages=ruby --exclude=.git --exclude=log -f .tags . $(bundle list --paths)