Skip to content

Nested $^X launch fails after EnvDir -clean clears Java launcher environment #1465

Closed

Description

@fglock

Summary

The EnvDir distribution fails t/10_envdir_pl.t on PerlOnJava when envdir.pl runs a child $^X after loading EnvDir -clean.

Evidence

  • Distribution: EnvDir-0.08
  • Failing test: t/10_envdir_pl.t
  • CPAN run: 20260921-102914-97159
  • Source: CPAN random tester run 20260921-102914-97159
  • PerlOnJava result: 25/26 tests passed; 1/7 test programs failed
  • Standard Perl oracle: all 26 tests passed

The failing test expects:

FOO=foo
PATH=/env/bin

but the child produces no output and reports:

ERROR: PerlOnJava requires Java 24 or later; java was not found in PATH.

Reproduction

bin/envdir.pl uses:

use EnvDir 'envdir', -clean;

EnvDir -clean clears %ENV and sets PATH=/bin:/usr/bin; the test environment then overrides PATH with /env/bin. This removes the inherited PERLONJAVA_JAVA_BIN value. The child $^X is PerlOnJava's launcher shim, which then cannot locate Java and exits before running the requested child code.

The parent launcher works when PERLONJAVA_JAVA_BIN=/usr/bin/java is explicitly preserved, confirming that the failure is in launching a nested PerlOnJava process from a cleaned/restricted environment rather than in EnvDir's normal variable update behavior.

Expected behavior

A PerlOnJava program should be able to invoke $^X after deliberately modifying or cleaning %ENV, as standard Perl does. The nested launcher should retain or otherwise reliably locate the Java executable without requiring java to remain on the child process's modified PATH.

Suggested direction

Make the nested $^X launcher self-contained with respect to Java selection, or arrange for the selected Java path to survive launcher recursion without violating EnvDir -clean's requested child environment semantics. Add a regression test covering a nested $^X invocation after environment cleanup.

Activity

  1. fglock commented on Oct 12, 2026

    @fglock
    OwnerAuthor

    Additional CPAN verification evidence:

    • Distribution: EnvDir-0.08
    • Test: t/10_envdir_pl.t
    • CPAN random tester run: 20261011-174632-64969
    • PerlOnJava: 25/26 tests passed; the child $^X launch failed after PATH was restricted to /env/bin, with java was not found in PATH.
    • System Perl 5.42.2: all 26 tests passed.
    • MetaCPAN reverse dependencies: 0 unique runtime dependants, 0 recent dependants.

    Please include t/10_envdir_pl.t from this run in verification after the nested launcher fix.

  2. added
    area:platformOperating-system-specific behavior
    area:runtimeCore Perl runtime semantics
    bugSomething isn't working
    on Oct 23, 2026
  3. fglock commented on Oct 24, 2026

    @fglock
    OwnerAuthor

    Resolved by merged PR #1879 (merge commit 57b8c18). The new jperl_nested_launch_clean_env.t regression test reproduces the critical EnvDir -clean condition by dropping inherited launcher variables and restricting PATH to a directory without Java, then verifies a nested $^X launch succeeds. The PR CI passed on Windows and Ubuntu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:platformOperating-system-specific behaviorarea:runtimeCore Perl runtime semanticsbugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions