linux-test-project / lcov

LCOV
GNU General Public License v2.0
867 stars 235 forks source link

Local installs not working correctly with relative paths #237

Closed billschereriii closed 8 months ago

billschereriii commented 10 months ago

I'm running into some difficulties with LCOV 2.0 local installs.

Platform: MacOS Ventura 13.3.1/LCOV 2.0 (github branch "v2.0")/perl 5.30

When I perform a local install, I am seeing different behavior depending on whether I set the PREFIX to a relative or absolute path. In both cases, make test from the LCOV root passes, but I see different behavior when trying to run LCOV from a directory other than the LCOV root:

With make PREFIX=pwd`/install install, I get the following regardless of which directory I run LCOV from:

$ install/bin/lcov
lcov: ERROR: invalid command line:
  install/bin/lcov
Need one of options -z, -c, -a, -e, -r, -l, --diff or --summary
Use lcov --help to get usage information

With make PREFIX=install install I get the above when running from the LCOV root, but the following when running from any other folder:

$ lcov/install/bin/lcov
Can't locate lcovutil.pm in @INC (you may need to install the lcovutil module) (@INC contains: install/lib/lcov /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.3 /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) at lcov/install/bin/lcov line 77.
BEGIN failed--compilation aborted at lcov/install/bin/lcov line 102.
henry2cox commented 10 months ago

Your first call worked the way it was expected to: lcov is trying to tell you that it expects a subcommand - and does not know what you want it to do. You might want to try install/bin/lcov --help or MANPATH=install/share/lcov/man man lcov (long path required because I suspect that you did not set your MANPATH).

Your second command failed because your PREFIX path was relative (not absolute) - and so the library path that got baked into the installed scripts is not visible from where you expected it to be. (You can call via PERL5LIB=/path/to/my/install/lib:$PERL5LIB .... if you really want to do things this way).

You might want to check to see what you PATH is set to.

billschereriii commented 10 months ago

Hi Henry,

I agree with your assessment. A couple comments:

  1. It's probably worth updating the documentation to flag that an absolute path is required for the prefix
  2. A friendlier approach would be to build an absolute path in the installer before passing it on to the rest of the installation
  3. I don't know enough about perl to know whether this is possible, but coming up with a way to give an error message that doesn't reference your internal library would be a good thing
henry2cox commented 10 months ago

for 1 and 2..it seems fairly straightforward to exchange the user's relative path (if any) for an abolute one - and use that. Possibly can warn the user what happened. I'll fix it.

for 3: it is kind of a normal perl thing - and you will see a similar message if some other required perl package is missing. Similar thing happens with Python, C++ - or any other languages I know of which use libraries.

billschereriii commented 10 months ago

Sounds great, thanks!

billschereriii commented 10 months ago

BTW, this came up as part of our migration from v1.12 to v2.0. We had been using a relative path with v1.12 and it didn't cause us any probpems there.

henry2cox commented 10 months ago

BTW, this came up as part of our migration from v1.12 to v2.0. We had been using a relative path with v1.12 and it didn't cause us any probpems there.

yeah...in refactoring the original implementation, I moved a lot of common code to the lcovutil module. Before that, lcov didn't use any of its own modules (only system-supplied ones) - and so the PERL5LIB path was not an issue.

billschereriii commented 10 months ago

It looks like you're assigning the first character to make variable FIRST_CHAR but then testing against FIRST -- typo?

henry2cox commented 10 months ago

damn.

henry2cox commented 10 months ago

fixed in 07a1127c2b4390abf4a516e9763fb28a956a9ce4

henry2cox commented 8 months ago

Closing this now, as I think it was fixed some time back. If there is still a problem, please either reopen this issue or file a new one. Please include a testcase and/or detailed directions for how to reproduce. Thanks Henry