Installing Perl in VSCode

Viewed 225

I am trying to go back in time a little and play around with Perl once again. I have a Mac and VSCode installed and did the following:

  • brew install perl to install perl
    • this installs perl at /opt/homebrew/bin/perl and perl --version returns "This is perl 5, version 34, subversion 0 (v5.34.0) built for darwin-thread-multi-2level"
  • cpanm Perl::LanguageServer to install the language server
  • and in VSCode I install the Perl extension by Gerald Richter (v2.3.0)

However, when I open create a new text file and set Perl as the file's language, I get the following error message:

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.

FOLLOW-UP:

In the meantime I uninstalled homebrew perl (brew uninstall perl), and rely on the already installed /usr/bin/perl ("This is perl 5, version 30, subversion 3 (v5.30.3) built for darwin-thread-multi-2level").

Using this version, I could install the language server and get it to run in VSCode. All I needed to do is select "File"->"Save Workspace As" to assign the ${workspace} variable of VSCode.

However, now I run into a new problem, as when I press F-5 (Run), I get the following error message:

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.

The library in question in ~/perl5/lib/perl5/Perl/LanguageServer. I assume I would have to add this directory to the module search path of VSCode - however not sure how.

FOLLOW-UP 2:

The module path can be added in the settings.json file belonging to the module. To get there click on "Perl" in the lower right corner of VSCode, and select "Configure 'Perl' based language settings" in the menu that pops up. This opens the settings.json file.

Once there, add the following line:

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

and you should be good to go. For some reason it has to be the full path, and ~/ is not interpolated.

0 Answers
Related