Language Server and Debug Protocol Adapter for Perl
You need to install the perl module Perl::LanguageServer to make this extension work,
Please make sure to always run the newest version of Perl::LanguageServer as well.
NOTE: Perl::LanguageServer depend on AnyEvent::AIO and Coro. There is a warning that this might not work with newer Perls. It works fine for Perl::LanguageServer. So just confirm the warning and install it.
Perl::LanguageServer depends on other Perl modules. It is a good idea to install most of then with your linux package manager.
e.g. on Debian/Ubuntu run:
e.g. on Centos 7 run:
In case any of the above packages are not available for your os version, just
leave them out. The cpan command will install missing dependencies. In case
the test fails, when running cpan
This extension contributes the following settings:
Debugger Settings for launch.json
Remote syntax check & debugging
If you developing on a remote machine, you can instruct the Perl::LanguageServer to run on that remote machine, so the correct modules etc. are available for syntax check and debugger is started on the remote machine. To do so set sshAddr and sshUser, preferably in your workspace configuration.
Also set sshWorkspaceRoot, so the local workspace path can be mapped to the remote one.
Example: if your local path is \10.11.12.13\share\path\to\ws and on the remote machine you have /path/to/ws
The other possibility is to provide a pathMap. This allows one to having multiple mappings.
Syntax check & debugging inside a container
You can run the LanguageServer and/or debugger inside
a container by setting
This will start the whole Perl::LanguageServer inside the container. This is espacally helpfull to make syntax check working, if there is a different setup inside and outside the container.
In this case you need to tell the Perl::LanguageServer how to map local paths
to paths inside the container. This is done by setting
It's also possible to run the LanguageServer outside the container and only
the debugger inside the container. This is especially helpfull, when the
container is not always running, while you are editing.
To make only the debugger running inside the container, put
Normaly the arguments for the
Working directory is not defined
It is not defined what the current working directory is at the start of a perl program. So Perl::LanguageServer makes no assumptions about it. To solve the problem you can set the directory via cwd configuration parameter in launch.json for debugging.
Module not found when debugging or during syntax check
If you reference a module with a relative path or if you assume that the current working directory is part of the Perl search path, it will not work. Instead set the perl include path to a fixed absolute path. In your settings.json do something like:
Include path works for syntax check and inside of debugger.
AnyEvent, Coro Warning during install
You need to install the AnyEvent::IO and Coro. Just ignore the warning that it might not work. For Perl::LanguageServer it works fine.
'richterger.perl' failed: options.port should be >= 0 and < 65536
Change port setting from string to integer
Error "Can't locate MODULE_NAME"
Please make sure the path to the module is in
ERROR: Unknown perlmethod _rpcnot_setTraceNotification
This is not an issue, that just means that not all features of the debugging protocol are implemented. Also it says ERROR, it's just a warning and you can safely ignore it.
The debugger sometimes stops at random places
Upgrade to Version 2.4.0
Message about Perl::LanguageServer has crashed 5 times
This is a problem when more than one instance of Perl::LanguageServer is running. Upgrade to Version 2.4.0 solves this problem.
The program I want to debug needs some input via stdin
You can read stdin from a file during debugging. To do so add the following parameter
If you are using Carton to manage dependencies, add the full path to the Carton
Does not yet work on windows, due to issues with reading from stdin. I wasn't able to find a reliable way to do a non-blocking read from stdin on windows. I would be happy, if anyone knows how to do this in Perl.
Anyway, Perl::LanguageServer runs without problems inside of Windows Subsystem for Linux (WSL).
For reporting bugs please use GitHub issues.
This is a Language Server and Debug Protocol Adapter for Perl
It implements the Language Server Protocol which provides syntax-checking, symbol search, etc. Perl to various editors, for example Visual Studio Code or Atom.
It also implements the Debug Adapter Protocol, which allows debugging with various editors/includes
To use both with Visual Studio Code, install the extension "perl"
Any comments and patches are welcome.
LICENSE AND COPYRIGHT
Copyright 2018-2022 Gerald Richter.
This program is free software; you can redistribute it and/or modify it under the terms of the Artistic License (2.0). You may obtain a copy of the full license at:
Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license.
If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license.
This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder.
This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed.
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.