Perl - Carton Installer Bug

Aperta
#2,416 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@Omnideth ci sta già lavorando.

Dal 6/11/2026.

  • #2417 di @Omnideth — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
csharp, docker, perl
Ambito
backend, devtools

Direzione di ricerca

Read PerlAppResourceBuilderExtensions.Dockerfile.cs, PerlAppResourceBuilderExtensions.PackageManager.cs, and PerlAppResourceBuilderExtensions.cs, then trace how WithLocalLib reaches Carton installation and environment setup in publish and run modes. Check the existing tests for Carton and cpanm behavior. Done means Carton installs into the configured root in both modes, environment variables and entrypoint paths use that root, and existing cpanm behavior is preserved.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Describe the bug

[Perl] WithCarton() + WithLocalLib() points PERL5LIB at a directory Carton never installs into

Carton always installs into <cpanfile dir>/local unless told otherwise via carton install --path=PATH or the
PERL_CARTON_PATH environment variable. The integration never passes either, but it still uses the
WithLocalLib(...) path for PERL5LIB / PERL_LOCAL_LIB_ROOT.

Publish (generated Dockerfile)

BuildCartonDockerfile
(called from #L292
with the resource's local::lib path):

  • #L371-L372:
    runs carton install --deployment / carton install with no --path, so modules land in /app/local.
  • #L384:
    copies /app from the build stage, so /app/local exists at runtime.
  • #L388-L389:
    sets PERL5LIB=/app/<localLibPath>/lib/perl5 and PERL_LOCAL_LIB_ROOT=/app/<localLibPath>, built from the
    WithLocalLib path.

With WithCarton().WithLocalLib("vendor/perl5"), the image has PERL5LIB=/app/vendor/perl5/lib/perl5, and that
directory doesn't exist. The app works only because of a separate hardcoded path:

That fallback doesn't cover these cases:

  • Executable entrypoints: BuildContainerEntrypointArguments returns [entrypoint] for
    EntrypointType.Executable, with no -I. Unless /app/local is on @INC some other way, the executable can't
    find Carton-installed modules.
  • Child Perl processes (system("perl ..."), prove, helper scripts) inherit the wrong PERL5LIB and don't
    get -I.
  • Tools that read PERL_LOCAL_LIB_ROOT see a root that doesn't exist.

The cpanm builder has the reverse, harmless problem. It installs into the WithLocalLib path and sets env vars
correctly, but the entrypoint still adds -Ilocal/lib/perl5 even when nothing is installed there.

Run mode (likely the same mismatch, not verified at runtime)
  • BuildProjectInstallArgs #L787-L789
    returns install / install --deployment for Carton and ignores localLibPath. Existing tests document this
    behavior: "Carton manages its own local directory; --local-lib is not used".
  • The installer and app still receive
    ApplyLocalLibEnvironment
    values (PERL5LIB, PERL_LOCAL_LIB_ROOT, PERL_MM_OPT=INSTALL_BASE=..., PERL_MB_OPT=--install_base ...)
    that point at the WithLocalLib path, while Carton installs into <appDir>/local.
  • Nothing runs the app through carton exec, and no run-mode -I points at local/lib/perl5. With a non-default
    WithLocalLib path, the app likely can't find its Carton modules in run mode. It also isn't clear whether the
    INSTALL_BASE / --install_base variables interfere with Carton's internal cpanm -L local call.
Regression

No response

Steps to reproduce
1. Create an app with `cpanfile` (for example `requires 'JSON::PP';`) and `cpanfile.snapshot`, and add an
   `Executable` entrypoint or a script that runs `system($^X, '-MJSON::PP', '-e', '1')`.
2. AppHost:

   
   builder.AddPerlScript("app", "../app", "app.pl")
       .WithCarton()
       .WithProjectDependencies()
       .WithLocalLib("vendor/perl5");
   

3. Publish, build the generated Dockerfile, and run the image. Then
   `docker run --rm <image> sh -c 'echo $PERL5LIB; ls /app/vendor/perl5; ls /app/local/lib/perl5'`.
4. Observe that `PERL5LIB` points at `/app/vendor/perl5/lib/perl5`, which doesn't exist, while modules are under
   `/app/local/lib/perl5`. The child Perl process or executable entrypoint fails with
   `Can't locate JSON/PP.pm` (or another non-core module).
5. Run mode: `aspire run` the same AppHost and check where `carton install` wrote modules versus the app's
   `PERL5LIB`.
Expected behavior

Carton honors WithLocalLib(...) regardless of fluent call order, and uses local when no path is configured.
The installer and application use the final configured root:

  • Run mode: resolve relative paths against the application's working directory. Set PERL_CARTON_PATH
    and PERL_LOCAL_LIB_ROOT to that root, and PERL5LIB to <root>/lib/perl5, on both the installer and app.
  • Publish mode: set PERL_CARTON_PATH in the generated build stage before carton install. Use
    /app/local by default, or /app/<configured relative path> for a custom path. The runtime image sets
    PERL_LOCAL_LIB_ROOT to that root and PERL5LIB to <root>/lib/perl5. Published environment variables
    use the same container paths, not host filesystem paths.
  • Entrypoints: generated Perl -I arguments use <root>/lib/perl5 for both Carton and cpanm.
    Executable entrypoints and child Perl processes can resolve installed modules through inherited PERL5LIB.
  • Installer options: do not inject PERL_MM_OPT or PERL_MB_OPT for Carton; Carton manages its own
    installer options. Preserve existing cpanm behavior.

Generated paths remain correctly quoted and escaped. This does not remove upstream Perl build-tool
limitations: Carton dependency installation can still fail for local::lib paths containing spaces.

Screenshots

No response

IDE and version

VS Code

IDE version

No response

Nuget packages

Additional context

No response

Help us help you

Yes, I'd like to be assigned to work on this item

Lingua principale
C#
Stelle
632
Fork
204
Merge medio
2g 13h
PR unite (30g)
92

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di CommunityToolkit/Aspire

Tutte le issue di CommunityToolkit/Aspire

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.