You need to enable JavaScript to run this app. 在Emacs中通过Cider运行Clojure项目时遇powershell.exe找不到错误
优惠活动
大模型
产品
解决方案
定价
更多

在Emacs中通过Cider运行Clojure项目时遇powershell.exe找不到错误

Cider jack-in报错找不到powershell.exe的解决办法

问题现象

执行cider-jack-in时触发以下错误:

ERROR: Unhandled REPL handler exception processing message {:op init-debuggereval, :code cljs.core/demunge, :session 9f9a0db9-8cc7-4cf0-b0ba-f426b163fb52, :id :nrepl.middleware.print/stream?7, :nrepl.middleware.print/print cider.nrepl.pprint/pprint, :nrepl.middleware.print/quota 1048576, :nrepl.middleware.print/buffer-size 4096, :nrepl.middleware.print/options {:right-margin 70}, :session 2f97cb2f-b111-4c37-8658-b63045c9ab2a, :id 6}
Syntax error macroexpanding at (clojuredocs.clj:19:32).

Caused by: java.io.IOException: Cannot run program "powershell.exe": CreateProcess error=2, The system cannot find the file specified

已配置系统和用户环境变量PATH包含PowerShell路径,Java版本为"20.0.1"。

解决步骤

  • 验证PowerShell路径的正确性:确认PowerShell的安装路径(通常为C:\Windows\System32\WindowsPowerShell\v1.0或C:\Program Files\PowerShell\7)已准确添加到系统PATH中,避免路径拼写错误或遗漏。
  • 重启Emacs及相关进程:修改环境变量后,完全关闭Emacs(包括后台运行的进程),重新启动后再尝试cider-jack-in,确保新的PATH配置被加载。若无效,尝试以管理员权限启动Emacs。
  • 手动指定Emacs的Shell配置:在Emacs配置文件中添加以下代码,强制指定使用PowerShell作为默认Shell:
    (setq shell-file-name "powershell.exe")
    (setq explicit-shell-file-name "powershell.exe")
    (setq shell-command-switch "-Command")
    
  • 检查Emacs的环境变量:在Emacs中执行M-! echo %PATH%,查看输出内容是否包含PowerShell的路径。若未包含,说明Emacs未正确读取系统环境变量,需重启电脑后再试。
  • 切换Java LTS版本:Java 20为非LTS版本,可能与Clojure、Cider存在兼容性问题,尝试切换至Java 11或17(长期支持版本),再执行cider-jack-in。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.17 16:33:23