Open matthew-lenz-otr opened 2 months ago
Hi @matthew-lenz-otr, thanks for filing the request. The Navigator intentionally doesn't use any executables other than perl
itself as specified by perlnavigator.perlPath
. For example, when running perlcritic
, it actually runs the script https://github.com/bscan/PerlNavigator/blob/main/server/src/perl/criticWrapper.pl with your specified version of perl. Similarly, perlimports and perltidy have their own wrappers. The advantage of this is that you only need to set a version of perl, and then all the related tools just work without requiring their own individual configuration.
Also, there are a few options available in the module forms that are unavailable in the command line form of these tools. For example, in perlcritic I need to pass the actual code via stdin (to run critic on unsaved files), but still specify a filename that is required for various policies (e.g. Perl::Critic::Policy::Modules::RequireFilenameMatchesPackage).
What are the issues you are having with SSH based development? I have tested the Perl Navigator extensively using the vscode SSH extension and it works well.
@bscan. I see the following in the log when I click on a script or module. Both perlcritic and perlimports are installed in vendor/{lib/perl5,bin}
[Trace - 12:25:11 PM] Sending notification 'textDocument/didOpen'. [Trace - 12:25:11 PM] Sending request 'textDocument/documentSymbol - (10)'. [Trace - 12:25:11 PM] Received request 'workspace/configuration - (12)'. [Trace - 12:25:11 PM] Sending response 'workspace/configuration - (12)'. Processing request took 0ms [Trace - 12:25:11 PM] Received response 'textDocument/documentSymbol - (10)' in 107ms. Found settings [Trace - 12:25:11 PM] Received request 'workspace/workspaceFolders - (13)'. [Trace - 12:25:11 PM] Sending response 'workspace/workspaceFolders - (13)'. Processing request took 0ms Now starting perlcritic with: /home/mlenz/.vscode-server/extensions/bscan.perlnavigator-0.8.15/server/src/perl/criticWrapper.pl --file /home/mlenz/projects/app/bin/afdl_completed Now starting perlimports with: /home/mlenz/.vscode-server/extensions/bscan.perlnavigator-0.8.15/server/src/perl/perlimportsWrapper.pl --lint --json --filename /home/mlenz/projects/app/bin/afdl_completed Starting perl compilation check with the equivalent of: perl -c -Mwarnings -M-warnings=redefine -I /home/mlenz/projects/app/vendor/lib/perl5 -I /home/mlenz/projects/app/lib -I /home/mlenz/.vscode-server/extensions/bscan.perlnavigator-0.8.15/server/src/perl -MInquisitor /home/mlenz/projects/app/bin/afdl_completed Attempted to run perlimports lint: Unable to run perlimports as it is not installed
Critic output: Skipping Perl::Critic as it is not installed
Ah, interesting. I think I see the issue.
This is using the default perlPath
which is simply the command perl
. Is there an alternative version of Perl installed in your local directory?
Specifically, if you run perl -MPerl::Critic -e 1
, does it work correctly?
If not, it seems like you have perl modules located in a place where perl doesn't normally look by default, which is ok. You can add extra parameters to pass to perl via the perlParams argument that was added in: https://github.com/bscan/PerlNavigator/pull/68 . So for example, you could try:
"perlnavigator.perlParams": [
"-I/home/mlenz/projects/app/vendor/lib/perl5",
]
This is what I'm using. You can see it in the logs above. It appears you are including that in the executable for certain executions? maybe just for starting the server? EDIT: no i'm not using alternate version of perl. No run like you show doesn't work because it needs the includePaths.
"perlnavigator.includePaths": [
"$workspaceFolder/vendor/lib/perl5"
],
Now I'm second guessing the design and naming of these parameters 🤔 . Currently, includePaths are only used when running perl -c
on your files for syntax checking, and commonly set to local project roots. The include paths are not used to find installed modules for running perlimports, perlcritic or perltidy. includePaths
also supports the $workspaceFolder
variable. I think of these as paths that are required for your project, but not for the configuration of perl itself. I did not think includePaths would hold the location of perlcritic, perltidy, or perlimports. In my own workflow, I typically use perlbrew, system perl, or PERL5LIB
, although I also think it's a reasonable approach to use the -I
flag for installed modules.
perlnavigator.perlParams
is a list of arguments always passed directly to perl. This could be a wide variety of things, including the -I
paths, or various different arguments to make perl and perl wrappers work. This is the core configuration of the executable itself, and does not currently support $workspaceFolder
. You should be able to use perlParams now to get it working (with the exception of $workspaceFolder
).
As for a fix to make this easier, I suppose are two options: I could either start using includePaths
when running critic/tidy/imports, or allow the use of $workspaceFolder
in perlParams.
Either solution is fine but not having $workspaceFolder support in perlParams makes it less flexible IMO EDIT: unusable when I want to have these settings saved in a shared .vscode/settings.json in the repo.
Not sure if you use any other executables other than perlimports but if I want perlimports to be included on 'develop' in my cpanfile and I want to use the workspaceFolder. My personal preference would be either a way to specify an additional PATH (so I can base it on $workspaceFolder) or just have a new option to specify the full path to perlimports, perlcritic ($workspaceFolder support would be useful here as well). For the life of me I can't get perl navigator to see these bins when i'm using remote - ssh based development.