richterger / Perl-LanguageServer

Language Server for Perl
Other
222 stars 53 forks source link

Missing example on container usage #70

Closed marema31 closed 3 years ago

marema31 commented 3 years ago

I've managed to make the extension running within a running container by tweaking the bin/shell-into-appserver.sh example described in the documentation, the linting and error checking works, but I'm not able to determine a correct launch.json file with the mapping magic. Can you add a such example in the documentation please.

richterger commented 3 years ago

Sorry, the container docs are contributed by an user. I personaly don't use it within containers. If you describe your problem more in detail, I might be able to help you.

geraldspreer commented 3 years ago

I've managed to make the extension running within a running container by tweaking the bin/shell-into-appserver.sh example described in the documentation, the linting and error checking works, but I'm not able to determine a correct launch.json file with the mapping magic. Can you add a such example in the documentation please.

Would you be willing to post the modified version of yourbin/shell-into-appserver.sh here? I am trying to get the language-server to work in Docker as well. Maybe we can figure it out together?

marema31 commented 3 years ago

Since I do not use docker compose, I've just modified it to use directly the docker exec command: ``

!/usr/bin/env bash

COMMAND=$(echo "$@" | sed 's/^.*perl /perl /') docker exec -i the_container $COMMAND

marema31 commented 3 years ago

One things I do not understand well, the $COMMAND contains perl -MPerl::LanguageServer -e Perl::LanguageServer::run -- --port 13603 --log-level 2 --version 2.1.0 does it means it's opening a listening port used by the vscode extension, in this case since this port is not published at docker run it is normal that is not working.

If it is the case, I will need the ability to provide the server address too because the containers are not running locally in my case but on shared ressources

geraldspreer commented 3 years ago

@marema31 Okay I see. I have got bin/shell-into-appserver.sh working with docker-compose. However I have trouble installing Perl::LanguageServer inside the container. But this has nothing to do with the LanguageServer, it's because of my particular project. I have not used Docker much but I guess you are right with the open ports. Maybe I start a new Perl project inside an Docker container and try it with just some modules installed.

geraldspreer commented 3 years ago

I have managed to get the Language Server running inside the Docker container and VSCode is connecting correctly. However I get this error:

Bareword "JSON::true" not allowed while "strict subs" in use at /usr/local/lib/perl5/site_perl/5.24.1/Perl/LanguageServer.pm line 260.
Bareword "JSON::false" not allowed while "strict subs" in use at /usr/local/lib/perl5/site_perl/5.24.1/Perl/LanguageServer.pm line 273.
Type of arg 1 to Coro::async must be block or sub {} (not reference constructor) at /usr/local/lib/perl5/site_perl/5.24.1/Perl/LanguageServer.pm line 305, near "} ;"
BEGIN not safe after errors--compilation aborted at /usr/local/lib/perl5/site_perl/5.24.1/Perl/LanguageServer.pm line 317.
Compilation failed in require.
BEGIN failed--compilation aborted.

After that the LanguageServer tries to restart four more times and is stopped. @richterger Do you have any suggestions?

richterger commented 3 years ago

These errors looks strange. Are the modules JSON and Coro installed inside the container?

geraldspreer commented 3 years ago

Yes, Coro and JSON are installed. I have installed Perl::LanguageServer with cpanm --installdeps

richterger commented 3 years ago

Do you see any errors when you run perl -MPerl::LanguageServer -e Perl::LanguageServer::run -- --port 13603 --log-level 2 P.S. The port is only necessary for the debugger

geraldspreer commented 3 years ago

@richterger This is the error I get when running perl -MPerl::LanguageServer -e Perl::LanguageServer::run -- --port 13603 --log-level 2 inside the container:

perl -MPerl::LanguageServer -e Perl::LanguageServer::run -- --port 13603 --log-level 2
Bareword "JSON::true" not allowed while "strict subs" in use at /usr/local/lib/perl5/site_perl/5.24.1/Perl/LanguageServer.pm line 260.
Bareword "JSON::false" not allowed while "strict subs" in use at /usr/local/lib/perl5/site_perl/5.24.1/Perl/LanguageServer.pm line 273.
Type of arg 1 to Coro::async must be block or sub {} (not reference constructor) at /usr/local/lib/perl5/site_perl/5.24.1/Perl/LanguageServer.pm line 305, near "} ;"
BEGIN not safe after errors--compilation aborted at /usr/local/lib/perl5/site_perl/5.24.1/Perl/LanguageServer.pm line 317.
Compilation failed in require.
BEGIN failed--compilation aborted.

P.S. I have checked the installation and it seems not to be correct. Even after cpanm --notest JSON::PP runs without any errors, cpanm --force Perl::LanguageServer fails with JSON::PP 2.27103 is not available

richterger commented 3 years ago

Please try to install either JSON::PP or JSON::XS manually

geraldspreer commented 3 years ago

Thank you @richterger for looking into this. I have found the solution, and there nothing wrong on your end. The problem is that the app that I have inherited includes some modules, including JSON::PP, hard into a local folder and sets PERL5LIB to load this local module. JSON::PP here is 0.9x. But when I adjust the paths in PERL5LIB to use the latest JSON::PP the language-server installs and runs without any problems. So it's all good. Again, thanks for looking into this.