Reputation: 2300
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
/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 serverHowever, 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.
Upvotes: 7
Views: 12288
Reputation: 300
On Ventura(13.1) this works for me:
brew install cpanm
. I don't know why we're using cpanm instead of cpan but I see it everywhere so I thought I'd use it too.cpanm Perl::LanguageServer
. This will fail but it's expected. It'll prompt you to set up cpan stuff. Set it up as default. Note that it'll probably say something like "Can't write to /Library/Perl/5.30 and /usr/local/bin: Installing modules to /Users/<username>/perl5"
. Remember this because vscode will mess up and miss this path.cpanm --force AnyEvent::AIO
. It's a dependency of Perl::LanguageServer.cpanm --force Coro
. It's a dependency of Perl::LanguageServer.cpanm Perl::LanguageServer
. Install the actual language server.perl -e "print \"@INC\";" | grep "/Users/<username>/perl5"
. @INC
stores the module search paths and we're looking for the paths that store what cpan installs. Note down the paths that contain "/Users/<username>/perl5"
. For my example output, the first four paths are what we're looking for./Users/<username>/perl5/lib/perl5/5.30.3/darwin-thread-multi-2level /Users/<username>/perl5/lib/perl5/5.30.3 /Users/<username>/perl5/lib/perl5/darwin-thread-multi-2level /Users/<username>/perl5/lib/perl5 /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
perlInc
in settings.json. "perl.perlInc": ["/Users/<username>/perl5/lib/perl5/5.30.3/darwin-thread-multi-2level",
"/Users/<username>/perl5/lib/perl5/5.30.3",
"/Users/<username>/perl5/lib/perl5/darwin-thread-multi-2level",
"/Users/<username>/perl5/lib/perl5"]
I figured this out from this thread and that comment in particular points out the problem: vscode's perl has different module search paths than those of terminal's perl. You can see this from doing perl -e "print \"@INC\";"
in both of them to see the difference.
Upvotes: 7
Reputation: 2603
On OS/X 12.6:
Upvotes: 3