-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GoToDefinition fails to find function in path added at runtime? #159
Comments
Hi @nospam2998, adding things at runtime normally works fine. The only issue is this line: use lib './'; It adds the path relative to the current working directory, which is not necessarily the same as the script path. If you run the You could update the script to be either fully pathed: use lib "/path/to/script"; Or if you want relative pathing use FindBin qw($Bin);
use lib "$Bin/"; And then in either case, the script can be run regardless of the working directory and Perl Navigator will also find the function from the runtime path. This is a good example of what we were discussing in #146, where it doesn't need the workspace folder, it just uses perl's file resolution logic. However, it doesn't assume any particular working directory for the compilation step. I'm closing this as resolved, but feel free to followup. |
Nice suggestion to use Since the ticket is already closed I will not investigate whether GitHub allows renaming issues, but a more descriptive title might have been GoToDefinition fails to work with relative paths. The only end-user documentation I've found is the README.md file, which has two possible injection points for a sentence highlighting the need for absolute paths. Either in the bullet point list Currently Implemented Features or in the text section Perl paths. With the Code Navigation point already being to long, the Perl paths seems like the best place. I also suggest moving the including to … dependencies part down there. Another improvement would be to actually strike the confusion-inducing relative path from that text. Essentially this could boil down to something like:
and
Please consider the above phrasing and see if you might agree to some of the suggested changes. As one understands from the filing of this issue, not knowing the cause of a problem causes wild geese to be chased. I filed the simplest possible example, but a fun thing to try is to move the module into the documented to be included sub-directory and doing a |
Sure, updated documentation is always a good idea. Thanks for the draft, I will make some modifications to the docs. I re-opened the ticket to track. One important clarification.
My core argument is that the script examples provided do not execute correctly. For example:
Which is pretty well aligned with the error from the PerlNavigator: I would argue that Although perhaps I am biased by my own workflow, where I rarely run scripts from their directory. For example, if I have a perl script in |
Your point was already clear, but thanks for elaborating on it. I'm not arguing that you. Absolute paths are definitely more correct than relying on pwd of the caller. However one thing to mention is that I have a close friend who is fully fluent in perl. One might think that's an odd and irrelevant fact to state here, and it would be. Unless I also added that he neither use any language server nor any linters as he think they just get in his way with bogus messages. For experts that might be the case. For us casual coders, one might argue the tools should be as helpful and forgiving as possible. Including idiot-proof instructions on how to hold the thing. I'm grateful for you pointing me at FindBin. It was new to me. Yet I'm not expecting software maintainers to train their users in everything vaguely related. My hope is that a reworded README.md might lead to fewer support requests, and thus a higher ratio of the more fun stuff for you. Please feel free to keep the conversion going, if keen on getting more of my input on the phrasing. |
To the best of my understanding this is not a duplicate of any other open issue. Please consider these two files:
Greeting.pm
and
hello
If attempting to GoToDefinition on
hello()
, it does findsub hello
. However when doing the same forsay_it()
my client gives me the message No definitions found, or to express is with was json-rpc:vs.
That's a bit unexpected to me, given how the description of PerlNavigator states:
I tried running the -MInquistor mentioned in #69, without really understanding the output. It does contain this row though:
Is this expected behaviour? It seems more trivial than the other reported failures of GoToDefinition, but maybe this is a duplicate after all? or another corner case which is hard to address?
The text was updated successfully, but these errors were encountered: