fix: @INC duplication and PERL_USE_UNSAFE_INC support#513
Merged
Conversation
Two bugs prevented Module::Install-based Makefile.PL scripts (e.g. Iterator::Simple) from running under jcpan: 1. @inc was duplicated at startup. GlobalContext.initializeGlobals() was called re-entrantly: during Builtin.initialize() an inheritFrom -> require -> doFile chain re-entered PerlLanguageProvider.executePerlCode, which ran the whole @inc population a second time because globalInitialized was only set to true AFTER initializeGlobals returned. Fixed by setting the flag BEFORE the call at all three call sites. 2. PERL_USE_UNSAFE_INC was ignored. CPAN.pm sets this env var when invoking Makefile.PL so that `use inc::Module::Install;` can find ./inc/Module/Install.pm. jperl now appends "." to @inc when PERL_USE_UNSAFE_INC is set to a truthy value. Verified with `./jcpan -t Iterator::Simple` (67 tests pass, 11 test files). Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes two bugs that prevented Module::Install-based
Makefile.PLscripts (e.g.Iterator::Simple) from running underjcpan.Bug 1:
@INCwas duplicated at startupGlobalContext.initializeGlobals()was being called re-entrantly. DuringBuiltin.initialize()(invoked from insideinitializeGlobals), aninheritFrom→require→doFilechain re-entersPerlLanguageProvider.executePerlCode, which checksglobalInitialized. Because the flag was only set totrueafterinitializeGlobalsreturned, the nested call ran the whole@INCpopulation a second time.Fix: set
globalInitialized = truebefore callinginitializeGlobals, at all three call sites.Bug 2:
PERL_USE_UNSAFE_INCwas ignoredModule::Install's
use inc::Module::Install;requires.in@INC. Modern Perl (5.26+) removed.from@INCby default, so CPAN.pm setsPERL_USE_UNSAFE_INC=1when invokingMakefile.PL.jperlwas ignoring this env var, making Module::Install-based distributions uninstallable.Fix:
GlobalContext.initializeGlobals()now appends.to@INCwhenPERL_USE_UNSAFE_INCis set to a truthy value.Test plan
./jperl -e 'print join("|", @INC), "\n"'shows no duplicates.PERL_USE_UNSAFE_INC=1 ./jperl -e 'print join("|", @INC), "\n"'ends with.../jcpan -t Iterator::Simple— all 67 tests across 11 files pass.make— all unit tests pass.Generated with Devin