windows 下 tramp 报错

现象: 最近一次重启我的Windows之后(公司电脑),用 find-file 打开地址为 ////plink:username@host:/的地址(只能输入4个"/"才能访问),报出以下错误:

  File error: [[Regexp ‘\(^[^#$%>
  ]*[#$%>] *\|\(?:^\|
  \)[^]#$%>
  ]*#?[]#$%>] *\(e\[[[:digit:];]*[[:alpha:]] *\)*\)\'’ not found in 10 secs]]

  File error: Couldn’t find local shell prompt for D:/Program Files/emacs-29.0.50/libexec/emacs/29.0.50/x86_64-w64-mingw32/cmdproxy.exe

  Error in post-command-hook (ivy--queue-exhibit): (file-error "Couldn’t find local shell prompt for D:/Program Files/emacs-29.0.50/libexec/emacs/29.0.50/x86_64-w64-mingw32/cmdproxy.exe")

无论是27,28 还是 29版本都会出现。同理,用 ssh-deploy 同步也报出相同错误 。

猜测: 可能和windows下面的shell相关。

相关现象:

  1. 本次重启电脑之后,打开powershell,然后不定时的会出现以下报错:
[0x7FF88F1B4F50] ANOMALY: meaningless REX prefix used

打开cmd就不会出现这个报错。从这个链接可以看到,这个错误可能和安全软件有关。查看软件列表,的确在这个问题发生的同时,公司给我又安装了一个叫DSIP的数据加密和信息安全软件。

  1. 双击emacs目录下的addpm.exe文件,也报出这个错误
[0x7FF88F1B4F50] ANOMALY: meaningless REX prefix used

不确定tramp这个报错和[0x7FF88F1B4F50]这个错误有没有关系。由于两个错误出现时间完全一致,所以放上来请教大家。

自己解决了。

首先用 M-x apropos-value,查到值为 D:/Program Files/emacs-29.0.50/libexec/emacs/29.0.50/x86_64-w64-mingw32/cmdproxy.exe 的变量和当前问题相关的只有一个 tramp-encoding-shell,

把它改为 cmd.exe, tramp 相关问题解决。

根据这个链接,cmdproxy.exe是用来解决早期 windows 版本中 “/c” 和 "-c“ 转换问题的。如果是新版本 windows,可以不用这个 cmdproxy.exe。