richterger / Perl-LanguageServer

Language Server for Perl
Other
224 stars 53 forks source link

Unable to set environment variables for debugged process #12

Closed gadgetjunkie closed 4 years ago

gadgetjunkie commented 4 years ago

If I try to set an environment variable for a debug session using the "env" section of a launch.json config entry, I get the following error in a popup in vs code as well as the output window for the perl language server:

Attribute (env) does not pass the type constraint because: Validation failed for 'ArrayRef' with value HASH(0x56474f7cd1b8) at /usr/local/lib/x86_64-linux-gnu/perl/5.26.1/Moose/Object.pm line 24
    Moose::Object::new('Perl::LanguageServer::DebuggerProcess', 'HASH(0x56474f7cd2f0)') called at /usr/local/share/perl/5.26.1/Perl/LanguageServer/Methods/DebugAdapter.pm line 418
    Perl::LanguageServer::Methods::DebugAdapter::_dapreq_launch('Moose::Meta::Class::__ANON__::SERIAL::4=HASH(0x56474f7cceb8)', 'Perl::LanguageServer::Workspace=HASH(0x56474ee941d8)', 'Perl::LanguageServer::Req=HASH(0x56474fab3a88)') called at /usr/local/share/perl/5.26.1/Perl/LanguageServer.pm line 220
    Perl::LanguageServer::call_method('Moose::Meta::Class::__ANON__::SERIAL::4=HASH(0x56474f7cceb8)', 'HASH(0x56474faa58a8)', 'Perl::LanguageServer::Req=HASH(0x56474fab3a88)', -2) called at /usr/local/share/perl/5.26.1/Perl/LanguageServer.pm line 250
    eval {...} at /usr/local/share/perl/5.26.1/Perl/LanguageServer.pm line 249
    Perl::LanguageServer::__ANON__ at /usr/local/lib/x86_64-linux-gnu/perl/5.26.1/Coro.pm line 716
    Coro::_coro_run at -e line 0

My launch.json looks like this:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "perl",
            "request": "launch",
            "name": "Perl-Debug",
            "program": "${workspaceFolder}/${relativeFile}",
            "stopOnEntry": true,
            "reloadModules": true,
            "env": {
                "MFTEST": "FOOBAR"
            }
        }
    ]
}

Also, I notice that if I don't specify an "env" option in the launch config, the global %ENV hash in the debugged process has been stripped of all entries except "PERL5DB", "PLSDI_OPTIONS", "PLSDI_REMOTE", even if there were env entries set prior to launching vs code.

richterger commented 4 years ago

That’s a bug in the current version and will be fixed in the next release. Workaround until the fix is to use a an array e.g.

"env": [ "MFTEST", "FOOBAR"

        ]

Von: Mike Williams [mailto:notifications@github.com] Gesendet: Mittwoch, 11. März 2020 17:39 An: richterger/Perl-LanguageServer Perl-LanguageServer@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Betreff: [richterger/Perl-LanguageServer] Unable to set environment variables for debugged process (#12)

If I try to set an environment variable for a debug session using the "env" section of a launch.json config entry, I get the following error in a popup in vs code as well as the output window for the perl language server:

Attribute (env) does not pass the type constraint because: Validation failed for 'ArrayRef' with value HASH(0x56474f7cd1b8) at /usr/local/lib/x86_64-linux-gnu/perl/5.26.1/Moose/Object.pm line 24 Moose::Object::new('Perl::LanguageServer::DebuggerProcess', 'HASH(0x56474f7cd2f0)') called at /usr/local/share/perl/5.26.1/Perl/LanguageServer/Methods/DebugAdapter.pm line 418 Perl::LanguageServer::Methods::DebugAdapter::_dapreq_launch('Moose::Meta::Class::ANON::SERIAL::4=HASH(0x56474f7cceb8)','Perl::LanguageServer::Workspace=HASH(0x56474ee941d8)','Perl::LanguageServer::Req=HASH(0x56474fab3a88)') called at/usr/local/share/perl/5.26.1/Perl/LanguageServer.pm line 220 Perl::LanguageServer::call_method('Moose::Meta::Class::ANON::SERIAL::4=HASH(0x56474f7cceb8)', 'HASH(0x56474faa58a8)','Perl::LanguageServer::Req=HASH(0x56474fab3a88)', -2) called at/usr/local/share/perl/5.26.1/Perl/LanguageServer.pm line 250 eval {...} at /usr/local/share/perl/5.26.1/Perl/LanguageServer.pmline 249 Perl::LanguageServer::ANON at/usr/local/lib/x86_64-linux-gnu/perl/5.26.1/Coro.pm line 716 Coro::_coro_run at -e line 0My launch.json looks like this:{ // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit:https://go.microsoft.com/fwlink/?linkid=830387<https:/ /urlsand.esvalabs.com/?u=https%3A%2F%2Fgo.microsoft.com%2Ffwlink%2F%3Flinkid%3D830387&e=09b421e4&h=ed1ae1d0&f=y&p=y> "version": "0.2.0", "configurations": [ { "type": "perl", "request": "launch", "name": "Perl-Debug", "program": "${workspaceFolder}/${relativeFile}", "stopOnEntry": true, "reloadModules": true, "env": { "MFTEST": "FOOBAR" } } ]}Also, I notice that if I don't specify an "env" option in the launch config,the global %ENV hash in the debugged process has been stripped of allentries except "PERL5DB", "PLSDI_OPTIONS", "PLSDI_REMOTE", even if therewere env entries set prior to launching vs code.—You are receiving this because you are subscribed to this thread.Reply to this email directly, view it on GitHubhttps://urlsand.esvalabs.com/?u=https%3A%2F%2Fgithub.com%2Frichterger%2FPerl-LanguageServer%2Fissues%2F12&e=09b421e4&h=5b74c576&f=y&p=y , orunsu bscribehttps://urlsand.esvalabs.com/?u=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAAS25ZYVXF37YCLQUS27SNLRG65CXANCNFSM4LFZ65CA&e=09b421e4&h=d5dc63ef&f=y&p=y .--This message has been checked by Libraesva ESG and is found to be clean.Mark it as spamhttp://srvmailgw3.i.ecos.de/cgi-bin/learn-msg.cgi?id=24DFF41E79.A0C8EBlacklist senderhttp://srvmailgw3.i.ecos.de/cgi-bin/learn-msg.cgi?blacklist=1&id=24DFF41E79.A0C8E

gadgetjunkie commented 4 years ago

Thanks for the prompt reply. I will use the work-around until the next release. Let me know if I can help with testing a fix, etc.

blelem commented 4 years ago

I am also having this issue, but somehow the workaround doesn't work on my setup. If I set:

"env": [
 "MFTEST", "FOOBAR"
]

I get a "Not a hash reference at debuggerProcess.pm line 128". @gadgetjunkie did the above work for you?

richterger commented 4 years ago

Fix is in commit 5c380be920de552d4ed56d491fe7fddee3cbf14f