PerlAlien / Alien-Build

Build external dependencies for use in CPAN
16 stars 25 forks source link

example/user/tool does not work #401

Closed jimav closed 1 year ago

jimav commented 1 year ago

The example code in example/user/tool/LZMA/Example.pm does not actually work.

It appears to work because the 'xz' program is already installed in my system. If I temporarily rename /usr/bin/xz then the example's lzma_version_string function returns undef.

I have Alien::xz v0.08 installed.

Most likely the problem is obvious; but I am newly trying to figure out Alien::Build and so don't know where to start. It would be helpful if the examples could be tested. Thanks.

#!/usr/bin/env perl
use strict; use warnings;

use File::Which;
BEGIN{
  if (my $path = File::Which::which("xz")) {
    die "$path exists;\n",
        "  You must rename or move it aside temporarily for this test\n";
  }
}

use lib "/home/jima/src/Alien-Build-2.79/example/user/tool/lib";
use LZMA::Example qw(lzma_version_string);

my $s = lzma_version_string();
die "Result is undef" unless defined($s);  # **DIES HERE**

print "GOT: $s\n";
plicease commented 1 year ago

This is expected if Alien::xz detected the system xz when it was installed. If you force a share install (which will build xz) then you should get the built xz

$ env ALIEN_INSTALL_TYPE=share cpanm --reinstall Alien::xz
plicease commented 1 year ago

...but... you are also right there is also a bug in the example .pm file.

plicease commented 1 year ago

I believe this to be fixed in 2.80. Please let me know if I missed something. Thank you for raising this issue!