Drop the hard `Pkg` dependency

Abierto
#446 0 comentarios 0 reacciones 0 asignados Ver en GitHub

@thchr ya está trabajando en esto.

Desde el 6/11/2026.

  • #449 de @thchr — abierto

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Refactorización
Claridad
Necesita aclaración
Estado de actividad
Tranquilo
Stack tecnológico
julia
Área
tooling

Línea de trabajo

Lee la declaración de dependencias y using Pkg en src/FileIO.jl; después, inspecciona los puntos de llamada obsoletos en src/deprecated.jl:50-67 y la ruta de carga activa en src/loadsave.jl:203. El issue presenta dos alternativas, así que primero confirma qué dirección prefieren los maintainers. Se considera terminado cuando se haya eliminado la dependencia innecesaria sin romper la ruta compatible no obsoleta, y el comportamiento obsoleto se gestione según la opción elegida.

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

Descripción

FileIO declares Pkg in [deps] and does using Pkg in src/FileIO.jl, but no non-deprecated code path uses it. Every Pkg.* call site (src/deprecated.jl:50-67) lives in the legacy add_loader/add_saver methods that are already marked # TODO: delete this method in FileIO v2. Since FileIO sits near the root of a large part of the ecosystem's dependency graph, every downstream package inherits Pkg into its closure and pays for it at using time.

The dependency dates to 0336017 (June 2019, the REQUIRE → Project.toml migration), when Pkg.installed() and Pkg.add were used to detect and install missing backends. Both uses are long gone; the live path loads backends with Base.require in src/loadsave.jl:203, which is pure Base.

The registry fallback is nearly unreachable

The remaining block resolves a package name to a UUID by scanning the installed registries, across three version-dependent branches. It only runs when Base.identify_package returns nothing — i.e. the package isn't a direct dep of the active project — but the PkgId it builds is then handed to Base.require, which needs the package in the load path anyway.

So it can only help when the package is an indirect dep: in the manifest, not a direct dep. Otherwise it either finds nothing or finds a UUID that fails at require later. That's a lot of machinery, plus a stdlib in every downstream closure, for a case callers can handle by passing name => uuid — which the non-deprecated API already asks for.

Option A — lazy load (non-breaking, 1.x)

Drop using Pkg and the [deps] entry; load on demand inside the deprecated method, which has already emitted a depwarn by that point:

const PKG_UUID = UUID("44cfe95a-1eb2-52ea-b672-e2afdf69b78f")
_load_pkg() = Base.require(Base.PkgId(PKG_UUID, "Pkg"))

and access Pkg.API.Context() etc. through the returned module. Identical behaviour for anyone on the deprecated path; everyone else stops paying.

Option B — delete the lookup (v2)

Resolve via Base.identify_package and Main only, and when both fail throw something actionable:

throw(ArgumentError("could not resolve package \"$pkgname\" from the active environment; " *
                    "pass it as a Module or as `\"$pkgname\" => uuid`"))
Lenguaje dominante
Julia
Estrellas
228
Forks
83
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

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 JuliaIO/FileIO.jl

Todos los issues de JuliaIO/FileIO.jl

Issues similares

Más issues de Julia

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.