richterger / Perl-LanguageServer

Language Server for Perl
Other
224 stars 53 forks source link

Can't locate Perl/LanguageServer.pm #52

Open ramogundogdu opened 3 years ago

ramogundogdu commented 3 years ago

I try to setup LanguageServer with VS Code & Perl Strawberry on Windows 10:

The command perl -v prints:

This is perl 5, version 32, subversion 0 (v5.32.0) built for MSWin32-x64-multi-thread

First I installed the VS Code extention Perl v2.1.0 Then I tried to install LanguageServer with the command in windows command Prompt "cpan Perl::LanguageServer". But I always get the following error:

...
t/02_signals.t ............. skipped: Broken perl detected, skipping tests.
t/03_child.t ............... skipped: Your perl interpreter is badly BROKEN. 

....

t/61_fltk_04_condvar.t ..... skipped: PERL_ANYEVENT_LOOP_TESTS not true
t/61_fltk_05_dns.t ......... skipped: PERL_ANYEVENT_LOOP_TESTS not true
t/61_fltk_07_io.t .......... skipped: PERL_ANYEVENT_LOOP_TESTS not true

....

Test Summary Report
-------------------
t/80_ssltest.t           (Wstat: 256 Tests: 415 Failed: 1)
  Failed test:  6
  Non-zero exit status: 1
Files=83, Tests=602,  5 wallclock secs ( 0.17 usr +  0.09 sys =  0.27 CPU)
Result: FAIL
Failed 1/83 test programs. 1/602 subtests failed.
gmake: *** [Makefile:899: test_dynamic] Error 255
  MLEHMANN/AnyEvent-7.17.tar.gz
  C:\Users\...\Tools\STRAWB~1\c\bin\gmake.exe test -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
  reports MLEHMANN/AnyEvent-7.17.tar.gz
Stopping: 'install' failed for 'AnyEvent'.

And when I open a perl project in VS Code I get the following OUTPUT:

Can't locate Perl/LanguageServer.pm in @INC (you may need to install the Perl::LanguageServer module) (@INC contains: C:/Users/.../Tools/Strawberry/perl/site/lib C:/Users/.../Tools/Strawberry/perl/vendor/lib C:/Users/.../Tools/Strawberry/perl/lib).
BEGIN failed--compilation aborted.
[Info  - 09:59:27] Connection to server got closed. Server will restart.

How can I make my environment in VS Code with LanguageServer run?

Thanks

ramogundogdu commented 3 years ago

I have installed now the LanguageServer with following command: cpanm -n Perl::LanguageServer But the Server can't be started. I get the following output:

tcp server start listen on port 13603
[Info  - 09:11:58] Connection to server got closed. Server will restart.
tcp server start listen on port 13603
[Info  - 09:11:58] Connection to server got closed. Server will restart.
tcp server start listen on port 13603

How can I make run the LanguageServer?

richterger commented 3 years ago

Try to set LogLevel to 2. Do you get more output?

ramogundogdu commented 3 years ago

Try to set LogLevel to 2. Do you get more output?

I have set LogLevel to 2. Unfortunately, I still get the same outputs. And by setting LogLevel to 2 I see the following note: LS: start aio read

Here you can see the errors: image

here how i installed the LanguageServer:

> cpanm -n Perl::LanguageServer Perl::LanguageServer is up to date. (2.1.0)

and the Version of Perl:

> perl -v This is perl 5, version 32, subversion 0 (v5.32.0) built for MSWin32-x64-multi-thread

richterger commented 3 years ago

Could try to run on the command line: perl -MPerl::LanguageServer -e Perl::LanguageServer::run -- --port 13603 --log-level 2 Please try with and without the --port Option and let me know if you see any error message

ramogundogdu commented 3 years ago

Could try to run on the command line: perl -MPerl::LanguageServer -e Perl::LanguageServer::run -- --port 13603 --log-level 2 Please try with and without the --port Option and let me know if you see any error message

I Although installed LanguageServer on Windows 10 as described above with no test, your command delivers the following: Can't locate Perl/LanguageServer.pm in @INC (you may need to install the Perl::LanguageServer module) I give up

richterger commented 3 years ago

AnyEvent, Coro, Compiler::Lexer, which are dependencies of LanguageServer all uses XS code, which needs to be compiled for the correct Perl version.

tg295 commented 3 years ago

@ramogundogdu I am experiencing a very similar issue, running: cpanm Perl::LanguageServer

produces: Perl::LanguageServer is up to date. (2.2.0)

But in attempting to debug a perl script in VSCode I receive: Can't locate Perl/LanguageServer/DebuggerInterface.pm in @INC (you may need to install the Perl::LanguageServer::DebuggerInterface module)

I tried installing Perl::LanguageServer::DebuggerInterface specifically but it doesn't seem to have fixed the issue.

Running the command @richterger described above:

Could try to run on the command line: perl -MPerl::LanguageServer -e Perl::LanguageServer::run -- --port 13603 --log-level 2 Please try with and without the --port Option and let me know if you see any error message

I receive the same error as @ramogundogd, with and without: Can't locate Perl/LanguageServer.pm in @INC (you may need to install the Perl::LanguageServer module)

I am on Mac Catalina.

richterger commented 3 years ago

Please try to set perl.perlInc so Perl::LanguageServer could be found. I guess the perl include path setting is differnt on the command line and when running form VSCode. One reason for this could be that VSCode starts a differnt Perl binary, that you are starting on the command line.

jayoung commented 2 years ago

hi, I am experiencing a similar issue. I feel like I'm close to having a solution, but not quite there. I'm a new user to VScode but have been using perl for years.

I'm on a Mac, VSCode Version: 1.61.0. I installed the Perl extension and started trying to debug a simple script:

#!/usr/bin/perl
print "hello\n";

I initially had errors within VSCode related to installing Perl::LanguageServer but I solved that by doing cpanm Perl::LanguageServer.pm from a Terminal window (regular Terminal, not VSCode terminal).

Perl::LanguageServer is now installed in a local dir (/Users/jayoung/perl5/lib/perl5) which is set as PERL5LIB in my bash .profile. Calling a perl script that includes the line use Perl::LanguageServer from the regular Terminal works fine, so I think it installed correctly.

Also I think this tells me it installed fine: from the regular Terminal command line I see this:

JanetYoungMBP16:temp jayoung$ cpanm Perl::LanguageServer
! Can't write to /Library/Perl/5.30 and /usr/local/bin: Installing modules to /Users/jayoung/perl5
! To turn off this warning, you have to do one of the following:
!   - run me as a root or with --sudo option (to install to /Library/Perl/5.30 and /usr/local/bin)
!   - Configure local::lib in your existing shell to set PERL_MM_OPT etc.
!   - Install local::lib by running the following commands
!
!         cpanm --local-lib=~/perl5 local::lib && eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
!
Perl::LanguageServer is up to date. (2.3.0)

JanetYoungMBP16:temp jayoung$ perl -MPerl::LanguageServer -e Perl::LanguageServer::run -- --port 13603 --log-level 2
##### 0 #####
 running: {} coros: {}
LS: start aio read, buffer len = 0
LS: start aio read, buffer len = 0
tcp server start listen on port 13603
tcp_bind: Address already in use at /Users/jayoung/perl5/lib/perl5/Perl/LanguageServer.pm line 497.

I also added a couple of lines to my VSCode settings.json file that I think are successfully telling VScode and the perl debugger to add my local library dir to @INC:

"perl.perlCmd": "/usr/bin/perl",
    "perl.perlInc": [

        "/Users/jayoung/perl5/lib/perl5 /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"
    ],

Perl scripts look great when I open them in VSCode - very nice formatting. But when I try to run Perl-Debug, it cannot find the module. It DOES look like it has my local lib dir at the beginning of the @INC path:

Can't locate Perl/LanguageServer/DebuggerInterface.pm in @INC (you may need to install the Perl::LanguageServer::DebuggerInterface module) (@INC contains: /Users/jayoung/perl5/lib/perl5 /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 /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.2 /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.

This is where DebuggerInterface.pm is:

JanetYoungMBP16:temp jayoung$ ls -l  /Users/jayoung/perl5/lib/perl5/Perl/LanguageServer/DebuggerInterface.pm 
-r--r--r--  1 jayoung  staff  45848 Jul 11 17:43 /Users/jayoung/perl5/lib/perl5/Perl/LanguageServer/DebuggerInterface.pm

Any suggestions of what's going wrong, and why the debugger isn't recognizing the contents of /Users/jayoung/perl5/lib/perl5 ?

thanks very much for any suggestions,

Janet Young

roamshome commented 2 years ago

I have installed the Perl::LanguageServer in my local::lib. When using the local::lib appropriately, it will updated your PERL5LIB environment variable to include the location of any libraries you installed there. However, I recall problems with the Perl extension in VS Code: it doesn't import your environment variables. On Linux I have patched this by automatically recreating all my environment variables in my launch.json file.

But you can try what happens if you manually set your "env" variable, and include PERL5LIB in there (careful, the extension currently doesn't use a hash, but an array of key/value pairs).

HOWEVER: it sounds like you can't even get the Perl::LanguageServer installed? The culprit seems to be AnyEvent::Loop. And that scares me a bit, because the event handler is exactly the type of problems you will find on WSL, not finding the correct map to the Windows10 system calls.

What happens if you try to install AnyEvent::Loop independently?

@dseynhae How do you recreate local:l:ib environment variables in launch.json file?

Julia-M-M commented 2 years ago

I had the same problem with macos and I solved it by force installing "AnyEvent" with cpanm instead of cpan cpanm AnyEvent --force

From there I followed the other installations:

  1. cpanm AnyEvent::AIO
  2. cpanm Perl::LanguageServer

And VSCode worked!

ddlakoduk commented 2 years ago

Does the Marketplace version of Perl Navigator Language Server for Visual Studio Code serve the same purpose or address the same need as the Perl::LanguageServer? https://marketplace.visualstudio.com/items?itemName=bscan.perlnavigator

I've had the same issues as others presented here. Repeated attempts to use cpanm to install modules have failed with dependency issues and reported a broken Perl installation. I did not use the --force option for the package installs. Reinstalling strawberry Perl, removing Perl::LanguageServer I no longer see the error messages in the VSCode output.

chuckkahn commented 2 years ago

with and without port option:

> 
perl -MPerl::LanguageServer -e Perl::LanguageServer::run -- --port 13603 --log-level 2
##### 0 #####
 running: {} coros: {}
LS: start aio read, buffer len = 0
LS: start aio read, buffer len = 0
tcp server start listen on port 13603
##### 1 #####
 running: {} coros: {}
##### 2 #####
 running: {} coros: {}
##### 3 #####
 running: {} coros: {}
perl -MPerl::LanguageServer -e Perl::LanguageServer::run -- --log-level 2
##### 0 #####
 running: {} coros: {}
LS: start aio read, buffer len = 0
LS: start aio read, buffer len = 0
##### 1 #####
 running: {} coros: {}
SuperStar888 commented 1 year ago

Now I got same issue, VSCode in Windows 10 Perl version is 5.32.1 How do I solve this out?

michaelbrundage commented 1 year ago

What I needed to do (MacOS) per earlier comment https://github.com/richterger/Perl-LanguageServer/issues/52#issuecomment-1099211202:

# install cpanm
curl -kL http://cpanmin.us | perl - App::cpanminus

# install LanguageServer
cpanm AnyEvent --force
cpanm AnyEvent::AIO
cpanm Perl::LanguageServer

Change the extension Perl Inc path per earlier comment https://github.com/richterger/Perl-LanguageServer/issues/52#issuecomment-877805330 It was null; I set it to my local Perl directory where things were installed: [ "/Users/yourname/perl5/lib/perl5" ] I also changed the extension setting Perl: Container mode from exec to run. I don't know if that was required but it seemed more correct given I'm not running docker, K8s, etc.

After all that (and restarting VSCode for good measure), this extension is working without further error.

santiagofn commented 1 year ago

I had to add another step to make this work in Ubuntu (22.04 / 22.10):

  1. Install cpanminus (see the options in https://metacpan.org/pod/App::cpanminus)
  2. install LanguageServer
    1. Install AnyEvent
      cpanm AnyEvent --force
    2. Install libperl-dev (as pointed out on https://rt.cpan.org/Public/Bug/Display.html?id=126277)
      sudo apt install libperl-dev
    3. Install AnyEvent::AIO
      cpanm AnyEvent::AIO
    4. Install the language server itself
      cpanm Perl::LanguageServer
caspergao commented 1 year ago

windown10 + strawberry perl + vscode:

in vscode output:

0

running: {} coros: {} LS: start aio read, buffer len = 0 LS: start aio read, buffer len = 0 tcp server start listen on port 13604 [Info - 11:04:53 AM] Connection to server got closed. Server will restart.

0

running: {} coros: {} LS: start aio read, buffer len = 0 LS: start aio read, buffer len = 0 tcp server start listen on port 13604 [Info - 11:04:55 AM] Connection to server got closed. Server will restart.

0

running: {} coros: {} LS: start aio read, buffer len = 0 LS: start aio read, buffer len = 0 tcp server start listen on port 13604 [Info - 11:04:57 AM] Connection to server got closed. Server will restart.

0

running: {} coros: {} LS: start aio read, buffer len = 0 LS: start aio read, buffer len = 0 tcp server start listen on port 13604 [Info - 11:04:58 AM] Connection to server got closed. Server will restart.

0

running: {} coros: {} LS: start aio read, buffer len = 0 LS: start aio read, buffer len = 0 tcp server start listen on port 13604 [Error - 11:05:00 AM] Connection to server got closed. Server will not be restarted.

but manual run command, looks fine:

C:\Users\egaolan>perl -MPerl::LanguageServer -e Perl::LanguageServer::run -- --port 13604 --log-level 2

0

running: {} coros: {} LS: start aio read, buffer len = 0 LS: start aio read, buffer len = 0 tcp server start listen on port 13604

1

running: {} coros: {}

2

running: {} coros: {}

3

running: {} coros: {} DAx: connect from 127.0.0.1:59855 DAx: start aio read, buffer len = 0 DAx: start aio read, buffer len = 0 DAx: end aio read cnt=21, buffer len = 21 DAx: line=<Content-Length: 512> DAx: start aio read, buffer len = 0 DAx: end aio read cnt=2, buffer len = 2 DAx: line=<> DAx: read data={"command":"initialize","arguments":{"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"perl","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en","supportsProgressReporting":true,"supportsInvalidatedEvent":true,"supportsMemoryReferences":true,"supportsArgsCanBeInterpretedByShell":true,"supportsMemoryEvent":true,"supportsStartDebuggingRequest":true},"type":"request","seq":1} DAx: read header={ "Content-Length" => 512 } DAx: ---> Request: { "command" : "initialize", "seq" : 1, "arguments" : { "supportsVariableType" : true, "supportsMemoryEvent" : true, "supportsArgsCanBeInterpretedByShell" : true, "supportsVariablePaging" : true, "locale" : "en", "supportsRunInTerminalRequest" : true, "clientName" : "Visual Studio Code", "supportsInvalidatedEvent" : true, "pathFormat" : "path", "columnsStartAt1" : true, "supportsMemoryReferences" : true, "supportsStartDebuggingRequest" : true, "supportsProgressReporting" : true, "clientID" : "vscode", "adapterID" : "perl", "linesStartAt1" : true }, .... ....

how to fix it? :)

wielandp commented 1 year ago

Windows+local perl is not supported, since AIO is not working. If you want to use it, think about using WSL. If you want to fix it, I have no idea :-)

see https://github.com/richterger/Perl-LanguageServer/issues/41#issuecomment-683338566