Skip to content

Core: declare SparseArrays in [extras] so the test target survives weakdep promotion - #4014

Merged
ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:fix-core-sparsearrays-extras
Jul 25, 2026
Merged

ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:fix-core-sparsearrays-extras

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

This PR should be ignored until reviewed by @ChrisRackauckas.

The failure

Downgrade Sublibraries / test (lib/OrdinaryDiffEqCore) aborts before a single
test runs:

`SparseArrays` declared as a `test` dependency, but no such entry in `extras` or `weakdeps`

Why

SparseArrays is in lib/OrdinaryDiffEqCore's test target but was listed
only under [weakdeps]. That resolves fine normally — Pkg looks the test
target up in [extras] and [weakdeps]. But julia-downgrade-compat promotes
a weak dependency to a real one when another package in the merged project
needs it, and in this job it does exactly that:

[ Info: Promoting root weak dependency required by OrdinaryDiffEqNonlinearSolve: SparseArrays

Promotion moves the entry out of [weakdeps] and into [deps]. The
test target is then pointing at a name that is in neither [extras] nor
[weakdeps], so Pkg.test errors out during test-environment generation.

This is the only Project.toml in the repo with a test-target name that lives in
[weakdeps] but not [extras]:

julia> for f in vcat(["Project.toml"], [joinpath("lib",d,"Project.toml") for d in readdir("lib")])
           d = TOML.parsefile(f)
           tgt = Set(get(get(d,"targets",Dict()),"test",String[]))
           extras = Set(keys(get(d,"extras",Dict()))); weak = Set(keys(get(d,"weakdeps",Dict())))
           w = setdiff(intersect(tgt, weak), extras)
           isempty(w) || println(f, ": ", sort(collect(w)))
       end
lib/OrdinaryDiffEqCore/Project.toml: ["SparseArrays"]

The fix

Also list SparseArrays in [extras]. [weakdeps] and [extensions] are
untouched, so OrdinaryDiffEqCoreSparseArraysExt still loads conditionally —
the entry only gives the test target a UUID that survives promotion.

Verification

1. Reproduced the CI failure locally by replaying the promotion step
(SparseArrays: [weakdeps] → [deps]) on unmodified master:

$ julia +1.11 --project=lib/OrdinaryDiffEqCore -e 'using Pkg; Pkg.test()'
ERROR: `SparseArrays` declared as a `test` dependency, but no such entry in `extras` or `weakdeps`

2. Same promotion, with this patch — the abort is gone and the test env builds:

      Status `~/claude_tmp/jl_Zb5Z9v/Project.toml`
Precompiling project for configuration --code-coverage=none ...
     Testing Running tests...

3. Normal (un-promoted) path still green — full Core group on Julia 1.11,
matching the CI job's ODEDIFFEQ_TEST_GROUP=Core:

$ ODEDIFFEQ_TEST_GROUP=Core julia +1.11 --project=lib/OrdinaryDiffEqCore -e 'using Pkg; Pkg.test()'
...
   2044.3 ms  ✓ OrdinaryDiffEqCore → OrdinaryDiffEqCoreSparseArraysExt
...
     Testing OrdinaryDiffEqCore tests passed

The extension still precompiles, confirming the [weakdeps] role is intact.

4. Both spellings resolve on every supported Julia — a minimal package with
SparseArrays in [weakdeps]+[extras] (normal) and in [deps]+[extras]
(post-promotion) passes Pkg.test on 1.10, 1.11 and 1.12.

Relation to other PRs

#4012 includes this same one-line change bundled with two unrelated fixes; this
PR isolates it.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TPHRh64BLfoXSzQ3AxKNwC

`SparseArrays` is in the `test` target but was only listed under
`[weakdeps]`. That resolves fine normally, but julia-downgrade-compat
promotes a weak dependency to a real one when some other package in the
merged project requires it — here OrdinaryDiffEqNonlinearSolve:

    [ Info: Promoting root weak dependency required by
            OrdinaryDiffEqNonlinearSolve: SparseArrays

Promotion moves the entry out of `[weakdeps]` and into `[deps]`, leaving
the `test` target pointing at a name that is in neither `[extras]` nor
`[weakdeps]`, so `Pkg.test` aborts before running anything:

    `SparseArrays` declared as a `test` dependency,
    but no such entry in `extras` or `weakdeps`

Listing it in `[extras]` too gives the target a UUID that survives the
promotion. Both spellings resolve on 1.10/1.11/1.12: pre-promotion
(`[weakdeps]` + `[extras]`) and post-promotion (`[deps]` + `[extras]`).

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review July 25, 2026 03:56
@ChrisRackauckas
ChrisRackauckas merged commit fe16494 into SciML:master Jul 25, 2026
118 of 123 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants