You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Emacs配置LSP-Metals时semgrep-ls启动失败问题求助

Emacs配置LSP-Metals与semgrep-ls冲突问题

配置背景

我在Emacs中配置lsp-metals时,直接使用官方页面提供的配置代码:

(use-package lsp-metals
  :ensure t
  :custom
  ;; You might set metals server options via -J arguments. This might not always work, for instance when
  ;; metals is installed using nix. In this case you can use JAVA_TOOL_OPTIONS environment variable.
  (lsp-metals-server-args '(;; Metals claims to support range formatting by default but it supports range
                            ;; formatting of multiline strings only. You might want to disable it so that
                            ;; emacs can use indentation provided by scala-mode.
                            "-J-Dmetals.allow-multiline-string-formatting=off"
                            ;; Enable unicode icons. But be warned that emacs might not render unicode
                            ;; correctly in all cases.
                            "-J-Dmetals.icons=unicode"))
  ;; In case you want semantic highlighting. This also has to be enabled in lsp-mode using
  ;; `lsp-semantic-tokens-enable' variable. Also you might want to disable highlighting of modifiers
  ;; setting `lsp-semantic-tokens-apply-modifiers' to `nil' because metals sends `abstract' modifier
  ;; which is mapped to `keyword' face.
  (lsp-metals-enable-semantic-highlighting t)
  :hook (scala-mode . lsp))

错误现象

打开Scala文件或启动scala-mode时,迷你缓冲区弹出错误:

Server semgrep-ls:1389372 exited (check corresponding stderr buffer for details). Do you want to restart it? (y or n) 

对应的*semgrep-ls:stderr*缓冲区内容:

Process semgrep-ls stderr finished
Fatal error: exception Git_wrapper.Error("run ['git' '-C' '/home/jake/src/helloworld' 'rev-parse'
     '--is-inside-work-tree']: No such file or directory")
Raised at Yojson__Safe.__ocaml_lex_read_object_sep_rec in file "lib/read.mll", line 698, characters 13-43
Called from Yojson__Safe.__ocaml_lex_read_json_rec in file "lib/read.mll", line 226, characters 23-47

注:报错中提到的/home/jake/src/helloworld路径实际存在,且我手动执行semgrep lsp --debug能正常启动服务,但Emacs无法复用该服务。

临时解决方法

禁用semgrep-ls客户端后问题消失:

(setq lsp-disabled-clients '(semgrep-ls))

求助需求

  • 后续的问题排查方向
  • 近期成功配置LSP-Metals的实用技巧
  • 如何正常启用semgrep-ls以获取其功能支持

内容的提问来源于stack exchange,提问作者Jake

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.15 15:48:21