在VSCode中安装Perl

nlejzf6q  于 2022-11-24  发布在  Perl
关注(0)|答案(1)|浏览(441)

我试着回到过去一点,再一次玩Perl。我安装了Mac和VSCode,并做了以下操作:

  • brew install perl以安装perl
  • 这将在/opt/homebrew/bin/perl安装perl,并且perl --version返回“这是为darwin-thread-multi-2level构建的perl 5,版本34,subversion 0(v5.34.0)”
  • cpanm Perl::LanguageServer以安装语言服务器
  • 并在VSCode中安装Gerald Richter的Perl扩展(v2.3.0)

但是,当我打开创建一个新文本文件并将Perl设置为该文件的语言时,我收到以下错误消息:

ListUtil.c: loadable library and perl binaries are mismatched (got handshake key 0xc700080, needed 0xfb80080)
[Info  - 12:52:54 PM] Connection to server got closed. Server will restart.
ListUtil.c: loadable library and perl binaries are mismatched (got handshake key 0xc700080, needed 0xfb80080)
[Info  - 12:52:54 PM] Connection to server got closed. Server will restart.
ListUtil.c: loadable library and perl binaries are mismatched (got handshake key 0xc700080, needed 0xfb80080)
[Info  - 12:52:54 PM] Connection to server got closed. Server will restart.
ListUtil.c: loadable library and perl binaries are mismatched (got handshake key 0xc700080, needed 0xfb80080)
[Info  - 12:52:54 PM] Connection to server got closed. Server will restart.
ListUtil.c: loadable library and perl binaries are mismatched (got handshake key 0xc700080, needed 0xfb80080)
[Error - 12:52:54 PM] Connection to server got closed. Server will not be restarted.

跟进:
同时,我卸载了homebrew perl(brew uninstall perl),并依赖于已经安装的/usr/bin/perl(“这是perl 5,版本30,subversion 3(v5.30.3),为darwin-thread-multi-2level构建的”)。
使用这个版本,我可以安装语言服务器并让它在VSCode中运行。我所需要做的就是选择“文件”-〉“将工作空间另存为”来分配VSCode的${workspace}变量。
但是,现在我遇到了一个新的问题,当我按F-5(运行)时,我得到以下错误消息:

Can't locate Perl/LanguageServer/DebuggerInterface.pm in @INC (you may need to install the Perl::LanguageServer::DebuggerInterface module) (@INC contains: /Library/Perl/5.30/darwin-thread-multi-2level /Library/Perl/5.30 /Network/Library/Perl/5.30/darwin-thread-multi-2level /Network/Library/Perl/5.30 /Library/Perl/Updates/5.30.3 /System/Library/Perl/5.30/darwin-thread-multi-2level /System/Library/Perl/5.30 /System/Library/Perl/Extras/5.30/darwin-thread-multi-2level /System/Library/Perl/Extras/5.30).
BEGIN failed--compilation aborted.

~/perl5/lib/perl5/Perl/LanguageServer中的库。我假设我必须将此目录添加到VSCode的模块搜索路径中-但不确定如何添加。
跟进2:
模块路径可以添加到属于模块的settings.json文件中。要添加到那里,请单击VSCode右下角的“Perl”,然后在弹出的菜单中选择“配置基于”Perl“的语言设置”。这将打开settings.json文件。
在此处添加以下行:

"perl.perlInc": [ "/Users/divingtobi/perl5/lib/perl5" ],

你应该可以走了。由于某种原因,它必须是完整的路径,而~/不是插值的。

szqfcxe2

szqfcxe21#

在OS/X 12.6上:
1.开放式CPAN

  1. cpan[1]〉强制安装AnyEvent::IO(忽略警告)
  2. cpan[2]〉强制安装科罗(忽略警告)
  3. cpan[3]〉安装Perl语言服务器
    1.启动VSC
    1.安装Perl扩展
    1.使用Perl和VSC获得乐趣

相关问题