perl Visual Studio代码更新后出现“内置端口转发”错误

xriantvc  于 2023-11-22  发布在  Perl
关注(0)|答案(1)|浏览(246)

在最新的Visual Studio代码更新之后,我的Perl扩展失败,输出如下:

  1. ""C:\StrawberryPerl\perl\bin\perl.exe" "-d" "X:\Perl\a.pl""
  2. Unable to connect to remote host: localhost:57937
  3. Compilation failed in require.
  4. at X:\Perl\a.pl line 0.
  5. main::BEGIN() called at X:\Perl\a.pl line 0
  6. eval {...} called at X:\Perl\a.pl line 0
  7. BEGIN failed--compilation aborted.
  8. at X:\Perl\a.pl line 0.

字符串
我相信原因是新的“内置端口转发”。我想,我的Perl extension使用端口5000,但我的VSC settings.json不包含一行"port": 5000

  1. {
  2. "launch": {
  3. "version": "0.2.0",
  4. "configurations": [
  5. {
  6. "type": "perl",
  7. "request": "launch",
  8. "name": "Perl-Debug local",
  9. "console": "externalTerminal",
  10. "program": "${file}",
  11. "exec": "C:\\StrawberryPerl\\perl\\bin\\perl.exe",
  12. "execArgs": [],
  13. "root": "${workspaceRoot}/",
  14. "inc": [],
  15. "args": [],
  16. "env": {},
  17. "debugRaw": false,
  18. "debugLog": false,
  19. "stopOnEntry": false,
  20. "sessions": "single"
  21. }
  22. ],
  23. "compounds": []
  24. },
  25. "terminal.external.windowsExec": "X:\\Perl\\vsc_cmd.cmd",
  26. "workbench.editor.tabSizing": "shrink",
  27. "editor.accessibilitySupport": "off",
  28. }


有办法修好吗?
我可以撤销“内置端口转发”吗?

polhcujo

polhcujo1#

我认为你有几个选择。你可以使用Windows Subsystem for Linux,其中这个扩展(Raix调试器)仍然以你所描述的方式工作。端口转发必须在WSL中以不同的方式处理。Perl::JavaServer调试器也可以在WSL中工作。
如果你想继续在原生Windows中使用Raix调试器,下面的配置在最新版本的vscode中也适用。将这些行添加到你的launch.json中:

  1. "sessions": "watch",
  2. "console": "remote",
  3. "port": 5000,

字符串
然后,当你启动调试器时,它将在“watch”模式下运行,等待Perl进程连接到扩展。要运行一个将连接的脚本,你可以使用这样的东西:

  1. cmd /C "set "PERLDB_OPTS=RemotePort=localhost:5000" && perl -d C:\Path\myScript.pl "


扩展的作者也建议你在以这种方式运行时使用Devel::vscode,但我还没有测试过。我通常也建议使用Perl Navigator来支持语言服务器(我是维护者),特别是在Windows中运行时。从长远来看,我想在Navigator中添加调试器支持,同时继续支持Windows。

相关问题