Skip Menu |

This queue is for tickets about the Gettext CPAN distribution.

Report information
The Basics
Id: 121458
Status: patched
Worked: 10 min
Priority: 0/
Queue: Gettext

People
Owner: PVANDRY [...] cpan.org
Requestors: KENTNL [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Tests fail when no '.' in @INC (Can't locate test_data/gen_test_data.pl in @INC )
Note: templated response follows

Perl 5.25.11 removes '.' from the default @INC, and this breaks `require "test_data/gen_test_data.pl"` due to not being able to assume ./test_data/gen_test_data.pl is in the @INC load path, and due to `require` treating paths without leading "/" or "./" as search paths.

This is not a complete end-of-the-world problem, as Perl provides a temporary workaround variable (PERL_USE_UNSAFE_INC=1) affected users can set that restores '.' in @INC temporarily to "just work", and for end users convenience, CPAN.pm, cpanm, prove and TAP::Harness ( called in `make test` ) set this variable, creating an illusion during installation that this problem is not there

However, this should still be considered a serious issue, as many types of end users don't get the luxury afforded by the CPAN-and-friends hacks ( vendors, hand installers, people running `perl t/foo.t` ), and this workaround is scheduled to be removed in the future.

And due to aforementioned temporary conveniences and hacks, you should intentionally defeat said hacks when testing you've fixed this, by explicitly setting PERL_USE_UNSAFE_INC=0 in your environment prior to running INSTALLER and tests, and ensuring to perform said tests on Perl 5.25.11 or newer

Two primary solutions are recommended for tests:

1. Re-organise test dependencies into a dedicated directory such as `t/lib` and load that path into @INC with `use lib 't/lib'`

2. Rewrite calls to `do` and `require` to have either absolute paths ( via `File::Spec rel2abs` ) or have explicit `./` prefixes, both of which disable @INC lookup

Both of these suggestions intentionally avoid the easier option of just reinserting `.` on purpose, as some proportion of runtime code also is subject to these cwd-implied bugs, and it is desirable to expose such cases as the errors they are, not silently suppress their failures

For more details, check http://blogs.perl.org/users/ryan_voots/2017/04/trials-and-troubles-with-changing-inc.html

---

Raw Error Observed:

perl -Mblib=blib t/frconvert.t
1..1
# Running under perl version 5.025012 for linux
# Current time local: Sun Apr 30 10:21:58 2017
# Current time GMT:   Sat Apr 29 22:21:58 2017
# Using Test.pm version 1.30
Can't locate test_data/gen_test_data.pl in @INC (@INC contains: blib/arch blib/lib /home/kent/perl5/perlbrew/perls/5.25.12-nossp-sip13-nopmc-nodot/lib/site_perl/5.25.12/x86_64-linux /home/kent/perl5/perlbrew/perls/5.25.12-nossp-sip13-nopmc-nodot/lib/site_perl/5.25.12 /home/kent/perl5/perlbrew/perls/5.25.12-nossp-sip13-nopmc-nodot/lib/5.25.12/x86_64-linux /home/kent/perl5/perlbrew/perls/5.25.12-nossp-sip13-nopmc-nodot/lib/5.25.12) at t/frconvert.t line 5.


perl -Mblib=blib t/jaconvert.t
1..1
# Running under perl version 5.025012 for linux
# Current time local: Sun Apr 30 10:24:03 2017
# Current time GMT:   Sat Apr 29 22:24:03 2017
# Using Test.pm version 1.30
Can't locate test_data/gen_test_data.pl in @INC (@INC contains: blib/arch blib/lib /home/kent/perl5/perlbrew/perls/5.25.12-nossp-sip13-nopmc-nodot/lib/site_perl/5.25.12/x86_64-linux /home/kent/perl5/perlbrew/perls/5.25.12-nossp-sip13-nopmc-nodot/lib/site_perl/5.25.12 /home/kent/perl5/perlbrew/perls/5.25.12-nossp-sip13-nopmc-nodot/lib/5.25.12/x86_64-linux /home/kent/perl5/perlbrew/perls/5.25.12-nossp-sip13-nopmc-nodot/lib/5.25.12) at t/jaconvert.t line 5.

perl -Mblib=blib t/raw.t
1..1
# Running under perl version 5.025012 for linux
# Current time local: Sun Apr 30 10:24:15 2017
# Current time GMT:   Sat Apr 29 22:24:15 2017
# Using Test.pm version 1.30
Can't locate test_data/gen_test_data.pl in @INC (@INC contains: blib/arch blib/lib /home/kent/perl5/perlbrew/perls/5.25.12-nossp-sip13-nopmc-nodot/lib/site_perl/5.25.12/x86_64-linux /home/kent/perl5/perlbrew/perls/5.25.12-nossp-sip13-nopmc-nodot/lib/site_perl/5.25.12 /home/kent/perl5/perlbrew/perls/5.25.12-nossp-sip13-nopmc-nodot/lib/5.25.12/x86_64-linux /home/kent/perl5/perlbrew/perls/5.25.12-nossp-sip13-nopmc-nodot/lib/5.25.12) at t/raw.t line 5.


 

-- 
- CPAN kentnl@cpan.org
- Gentoo Perl Maintainer kentnl@gentoo.org ( perl@gentoo.org )