richterger / Perl-LanguageServer

Language Server for Perl
Other
225 stars 52 forks source link

Connection error when trying to debug inside a container #213

Open samueldc opened 1 week ago

samueldc commented 1 week ago

Hi everyone,

I'm trying to debug a perl web application (OTRS) inside a container using Plack::Runner.

My VS Code launch.json file is:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "perl",
      "request": "launch",
      "name": "Perl-Plackup",
      "program": "/opt/otrs/bin/cgi-bin/debug.pl",
      // "args": ["-MPlack::Runner", "-e 'my $runner = Plack::Runner->new;$runner->parse_options(\"--port=3000\");$runner->run(\"/opt/otrs/bin/cgi-bin/app.psgi\");'"],
      "args": ["--port=3000"],
      "stopOnEntry": true,
      "reloadModules": true,
      "containerCmd": "docker",
      "containerMode": "exec",
      "containerName": "otrs-ditec-httpd-1",
      "pathMap": [
        [
          "file:///opt/otrs",
          "file:///workspaces/otrs-ditec"
        ]
      ],
      "env": {
        "PLSDI_REMOTE": "13604"  // Set any required environment variables
      }
    }
  ]
}

And I have a debug.pl file to run a plack web server:

use Plack::Runner;

my $runner = Plack::Runner->new;
#$runner->parse_options("--port=3000");
$runner->parse_options(@ARGV);
$runner->run("/opt/otrs/bin/cgi-bin/app.psgi");

But when I launch debug, get the following error message in the VS Code debug console:

Cannot connect to 127.0.0.1: (No such file or directory) at /usr/share/perl5/Perl/LanguageServer/DebuggerInterface.pm line 1696.
Compilation failed in require.
BEGIN failed--compilation aborted.

Checking at DebuggerInterface.pm line 1696, looks like the port is missing (just a guess). Tried to set PLSDI_REMOTE env variable both in launch.json and in docker-compose.yml but the error message keep the same.

Any thoughts?

Thanks in advance!

samueldc commented 1 week ago

Forgot to mention my environment:

Version of IDE/Editor plugin is 2.6.2 Version of Perl::LanguageServer is 2.5.0