Perl - Carton Installer Bug

Cerrado
#2,416 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Ya se ha fusionado un pull request relacionado.

  • #2417 de @Omnideth — fusionado

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
csharp, docker, perl
Área
backend, devtools

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
C#
Estrellas
632
Forks
204
Merge medio
2 d 18 h
PR fusionados (30 d)
99

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de CommunityToolkit/Aspire

Todos los issues de CommunityToolkit/Aspire

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.