# ERROR: KeyError: key "SparseArrays" not found

**URL:** <https://discourse.julialang.org/t/error-keyerror-key-sparsearrays-not-found/125980>\
**Category:** New to Julia\
**Tags:** package\
**Created:** [February 17, 2025, 10:36am UTC](https://discourse.julialang.org/t/error-keyerror-key-sparsearrays-not-found/125980 "2025-02-17T10:36:11Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eventine](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eventine/32/215272_2.png) [@Eventine](https://discourse.julialang.org/u/Eventine)\
**Post date:** [February 17, 2025, 10:36am UTC](https://discourse.julialang.org/t/error-keyerror-key-sparsearrays-not-found/125980/1 "2025-02-17T10:36:11Z")

</div>

I’m new to Julia, I had a project that was using ControlSystems and SparseArrays packages. After the weekend I came back to the office, lauched a test, and nothing was working. Basically it says that I cannot compile ControlSystems (why does it need to compile it again?) because the Key SparseArrays is missing.  
I spent 4h trying to debug the issue, and I’ve tried everything I could find, including all Pkg.x() commands (all failing with the same error “ERROR: KeyError: key “SparseArrays” not found”), and also deleting all local Julia Package, compiled, and environment files and restarting, just to find myself at the same point.

I’m kinda of lost, and a bit upset (I wanted to try Julia so much to move away from the shitty Python packages creating issues all the time).

Stack trace of me trying to recompile ControlSystems after I reset everything

```julia
ERROR: LoadError: Failed to precompile ControlSystems [a6e380b2-a6ca-5380-bf3e-84a91bcd477e] to "/path/.julia/compiled/v1.10/ControlSystems/jl_VwYKFv".
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, keep_loaded_modules::Bool)
    @ Base ./loading.jl:2468
  [3] compilecache
    @ ./loading.jl:2340 [inlined]
  [4] (::Base.var"#968#969"{Base.PkgId})()
    @ Base ./loading.jl:1974
  [5] mkpidlock(f::Base.var"#968#969"{Base.PkgId}, at::String, pid::Int32; kwopts::@Kwargs{stale_age::Int64, wait::Bool})
    @ FileWatching.Pidfile /tools/foss/julia/1.10.4/x86_64/gen_linux/share/julia/stdlib/v1.10/FileWatching/src/pidfile.jl:93
  [6] #mkpidlock#6
    @ /tools/foss/julia/1.10.4/x86_64/gen_linux/share/julia/stdlib/v1.10/FileWatching/src/pidfile.jl:88 [inlined]
  [7] trymkpidlock(::Function, ::Vararg{Any}; kwargs::@Kwargs{stale_age::Int64})
    @ FileWatching.Pidfile /tools/foss/julia/1.10.4/x86_64/gen_linux/share/julia/stdlib/v1.10/FileWatching/src/pidfile.jl:111
  [8] #invokelatest#2
    @ ./essentials.jl:894 [inlined]
  [9] invokelatest
    @ ./essentials.jl:889 [inlined]
 [10] maybe_cachefile_lock(f::Base.var"#968#969"{Base.PkgId}, pkg::Base.PkgId, srcpath::String; stale_age::Int64)
    @ Base ./loading.jl:2983
 [11] maybe_cachefile_lock
    @ ./loading.jl:2980 [inlined]
 [12] _require(pkg::Base.PkgId, env::String)
    @ Base ./loading.jl:1970
 [13] __require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1812
 [14] #invoke_in_world#3
    @ ./essentials.jl:926 [inlined]
 [15] invoke_in_world
    @ ./essentials.jl:923 [inlined]
 [16] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1803
 [17] macro expansion
    @ ./loading.jl:1790 [inlined]
 [18] macro expansion
    @ ./lock.jl:267 [inlined]
 [19] __require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1753
 [20] #invoke_in_world#3
    @ ./essentials.jl:926 [inlined]
 [21] invoke_in_world
    @ ./essentials.jl:923 [inlined]
 [22] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1746
 [23] include(fname::String)
    @ Base.MainInclude ./client.jl:489
 [24] top-level scope
    @ /path/test_sim.jl:9

```

Stacktrace of a Pkg.resolve()

```julia
ERROR: KeyError: key "SparseArrays" not found
Stacktrace:
  [1] getindex
    @ ./dict.jl:498 [inlined]
  [2] status_ext_info(pkg::Pkg.Types.PackageSpec, env::Pkg.Types.EnvCache)
    @ Pkg.Operations /tools/foss/julia/1.10.4/x86_64/gen_linux/share/julia/stdlib/v1.10/Pkg/src/Operations.jl:2214
  [3] print_status(env::Pkg.Types.EnvCache, old_env::Pkg.Types.EnvCache, registries::Vector{…}, header::Symbol, uuids::Vector{…}, names::Vector{…}; manifest::Bool, diff::Bool, ignore_indent::Bool, outdated::Bool, extensions::Bool, io::Base.TTY, mode::Pkg.Types.PackageMode, hidden_upgrades_info::Bool, show_usagetips::Bool)
    @ Pkg.Operations /tools/foss/julia/1.10.4/x86_64/gen_linux/share/julia/stdlib/v1.10/Pkg/src/Operations.jl:2299
  [4] print_status
    @ /tools/foss/julia/1.10.4/x86_64/gen_linux/share/julia/stdlib/v1.10/Pkg/src/Operations.jl:2241 [inlined]
  [5] status(env::Pkg.Types.EnvCache, registries::Vector{…}, pkgs::Vector{…}; header::Symbol, mode::Pkg.Types.PackageMode, git_diff::Bool, env_diff::Pkg.Types.EnvCache, ignore_indent::Bool, io::Base.TTY, outdated::Bool, extensions::Bool, hidden_upgrades_info::Bool, show_usagetips::Bool)
    @ Pkg.Operations /tools/foss/julia/1.10.4/x86_64/gen_linux/share/julia/stdlib/v1.10/Pkg/src/Operations.jl:2475
  [6] status (repeats 2 times)
    @ /tools/foss/julia/1.10.4/x86_64/gen_linux/share/julia/stdlib/v1.10/Pkg/src/Operations.jl:2443 [inlined]
  [7] #show_update#167
    @ /tools/foss/julia/1.10.4/x86_64/gen_linux/share/julia/stdlib/v1.10/Pkg/src/Operations.jl:2439 [inlined]
  [8] up(ctx::Pkg.Types.Context, pkgs::Vector{…}, level::Pkg.Types.UpgradeLevel; skip_writing_project::Bool, preserve::Nothing)
    @ Pkg.Operations /tools/foss/julia/1.10.4/x86_64/gen_linux/share/julia/stdlib/v1.10/Pkg/src/Operations.jl:1545
  [9] up
    @ /tools/foss/julia/1.10.4/x86_64/gen_linux/share/julia/stdlib/v1.10/Pkg/src/Operations.jl:1520 [inlined]
 [10] up(ctx::Pkg.Types.Context, pkgs::Vector{…}; level::Pkg.Types.UpgradeLevel, mode::Pkg.Types.PackageMode, preserve::Nothing, update_registry::Bool, skip_writing_project::Bool, kwargs::@Kwargs{})
    @ Pkg.API /tools/foss/julia/1.10.4/x86_64/gen_linux/share/julia/stdlib/v1.10/Pkg/src/API.jl:351
 [11] up
    @ /tools/foss/julia/1.10.4/x86_64/gen_linux/share/julia/stdlib/v1.10/Pkg/src/API.jl:326 [inlined]
 [12] up
    @ /tools/foss/julia/1.10.4/x86_64/gen_linux/share/julia/stdlib/v1.10/Pkg/src/API.jl:164 [inlined]
 [13] #resolve#143
    @ /tools/foss/julia/1.10.4/x86_64/gen_linux/share/julia/stdlib/v1.10/Pkg/src/API.jl:357 [inlined]
 [14] resolve
    @ /tools/foss/julia/1.10.4/x86_64/gen_linux/share/julia/stdlib/v1.10/Pkg/src/API.jl:356 [inlined]
 [15] resolve(; io::Base.TTY, kwargs::@Kwargs{})
    @ Pkg.API /tools/foss/julia/1.10.4/x86_64/gen_linux/share/julia/stdlib/v1.10/Pkg/src/API.jl:355
 [16] top-level scope
    @ REPL[5]:1
Some type information was truncated. Use `show(err)` to see complete types.

```

---

<div class="post-metadata">

**Author:** ![barucden](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/barucden/32/26154_2.png) [@barucden](https://discourse.julialang.org/u/barucden)\
**Post date:** [February 17, 2025, 10:51am UTC](https://discourse.julialang.org/t/error-keyerror-key-sparsearrays-not-found/125980/2 "2025-02-17T10:51:13Z")

</div>

Welcome to the forum!

Can you try to activate a temporary environment and add only ControlSystems.jl? You can do it as follows:

```julia-repl
julia> using Pkg

julia> Pkg.activate(temp=true)
  Activating new project at `/tmp/jl_ZjU2Cv`

julia> Pkg.add("ControlSystems")

```

Does it also fail to precompile, or does it succeed? You should be able to run

```julia-repl
julia> using ControlSystems

```

---

<div class="post-metadata">

**Author:** ![Eventine](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eventine/32/215272_2.png) [@Eventine](https://discourse.julialang.org/u/Eventine)\
**Post date:** [February 17, 2025, 10:55am UTC](https://discourse.julialang.org/t/error-keyerror-key-sparsearrays-not-found/125980/3 "2025-02-17T10:55:35Z")

</div>

Hi! Thank for the answer. I’ve already tried and gave me the same error.  
I forgot to mention that ofc “using SparseArrays” works like a charm and is basically the only command that does not give me errors

---

<div class="post-metadata">

**Author:** ![barucden](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/barucden/32/26154_2.png) [@barucden](https://discourse.julialang.org/u/barucden)\
**Post date:** [February 17, 2025, 11:02am UTC](https://discourse.julialang.org/t/error-keyerror-key-sparsearrays-not-found/125980/4 "2025-02-17T11:02:36Z")

</div>

I think you are getting the same error as reported here: [`status` can error when the RHS in `[extensions]` does not map to a weak dep · Issue #3947 · JuliaLang/Pkg.jl · GitHub](https://github.com/JuliaLang/Pkg.jl/issues/3947)

But I am not sure why does it happen in your case.

> [@Eventine](#):
>
> and also deleting all local Julia Package, compiled, and environment files and restarting, just to find myself at the same point.

Does that mean that you tried removing (or _rather renaming temporarily_) `~/.julia` and it still did not help? What happens if you check `] status` in your package environment?

```julia-repl
julia> using Pkg

julia> Pkg.status()

```

---

<div class="post-metadata">

**Author:** ![Eventine](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eventine/32/215272_2.png) [@Eventine](https://discourse.julialang.org/u/Eventine)\
**Post date:** [February 17, 2025, 11:13am UTC](https://discourse.julialang.org/t/error-keyerror-key-sparsearrays-not-found/125980/5 "2025-02-17T11:13:29Z")

</div>

Yep, I tried removing the .julia and nothiing changed.  
The Pkg.status() returns

```julia
Project NAME v0.1.0
Status `/path/NAME/Project.toml`
  [a6e380b2] ControlSystems v1.11.2
  [634d3b9d] DrWatson v2.18.0
  [2f01184e] SparseArrays v1.10.0

```

The initial project had way more packages, but I’ve been cleaning and resetting all morning.

Regarding the link you provided me, I did not get it very well (consider I’m new). Should I go into the Manifest.toml to search for SparseArraysExt?

---

<div class="post-metadata">

**Author:** ![barucden](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/barucden/32/26154_2.png) [@barucden](https://discourse.julialang.org/u/barucden)\
**Post date:** [February 17, 2025, 11:30am UTC](https://discourse.julialang.org/t/error-keyerror-key-sparsearrays-not-found/125980/6 "2025-02-17T11:30:35Z")

</div>

> [@Eventine](#):
>
> Regarding the link you provided me, I did not get it very well (consider I’m new). Should I go into the Manifest.toml to search for SparseArraysExt?

Not exactly. The error you posted is raised when an extension has a dependency that is not defined as a (weak) dependency (relevant part of the docs: [5. Creating Packages · Pkg.jl](https://pkgdocs.julialang.org/v1/creating-packages/#Conditional-loading-of-code-in-packages-(Extensions))).

The piece of code which raises the error has been modified since `v1.10` to provide a more informative message. Can you try to add the package with julia 1.11 by any chance?

---

<div class="post-metadata">

**Author:** ![Eventine](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eventine/32/215272_2.png) [@Eventine](https://discourse.julialang.org/u/Eventine)\
**Post date:** [February 17, 2025, 11:37am UTC](https://discourse.julialang.org/t/error-keyerror-key-sparsearrays-not-found/125980/7 "2025-02-17T11:37:22Z")

</div>

Sadly I cannot, since I’m using a shared cluster.  
Do you have any suggestions?  
Why Friday was working and now not? Can I install an older version of ControlSystem and SparseArrays?

---

<div class="post-metadata">

**Author:** ![barucden](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/barucden/32/26154_2.png) [@barucden](https://discourse.julialang.org/u/barucden)\
**Post date:** [February 17, 2025, 12:41pm UTC](https://discourse.julialang.org/t/error-keyerror-key-sparsearrays-not-found/125980/8 "2025-02-17T12:41:56Z")

</div>

I have no idea why your project stopped working. The dependencies do not change unless you explicitly ask for it (or change Project.toml manually).

Uh, I am out of my depth here. Let’s try to collect more information about the packages and their extensions:

```julia-repl
julia> using Pkg

julia> Pkg.status(extensions=true, mode=PKGMODE_MANIFEST)

```

This lists all the dependencies of your package together with their extensions and the dependencies of the extensions.

Edit: FWIW, I can add `ControlSystems` to a fresh environment without any issues in julia 1.10. Since you see the error in a fresh environment with a clean `~/.julia`, then I can only imagine something’s wrong with the Julia installation on your cluster. Perhaps something has changed over the weekend? Maybe you could install `juliaup` ([GitHub - JuliaLang/juliaup: Julia installer and version multiplexer](https://github.com/JuliaLang/juliaup?tab=readme-ov-file#mac-linux-and-freebsd)) and install julia to your home directory?

---

<div class="post-metadata">

**Author:** ![Eventine](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eventine/32/215272_2.png) [@Eventine](https://discourse.julialang.org/u/Eventine)\
**Post date:** [February 17, 2025, 1:00pm UTC](https://discourse.julialang.org/t/error-keyerror-key-sparsearrays-not-found/125980/9 "2025-02-17T13:00:06Z")

</div>

Yeah.  
I’ve decided to “rip off the patch” and I installed a personal julia (1.11 since I was at it). Now it works without any issues.  
Thanks anyway for your support

---

<div class="post-metadata">

**Author:** ![erik-f](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erik-f/32/18638_2.png) [@erik-f](https://discourse.julialang.org/u/erik-f)\
**Post date:** [February 19, 2025, 11:10am UTC](https://discourse.julialang.org/t/error-keyerror-key-sparsearrays-not-found/125980/10 "2025-02-19T11:10:02Z")

</div>

I also have this problem in CI with Julia 1.10 on Windows and macOS. Ubuntu is fine, and Julia 1.11 is also working on all platforms.

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [February 19, 2025, 1:40pm UTC](https://discourse.julialang.org/t/error-keyerror-key-sparsearrays-not-found/125980/11 "2025-02-19T13:40:25Z")

</div>

What patch version of v1.10? There were some issues with extensions, that had been fixed in latest patches.

---

<div class="post-metadata">

**Author:** ![erik-f](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erik-f/32/18638_2.png) [@erik-f](https://discourse.julialang.org/u/erik-f)\
**Post date:** [February 19, 2025, 3:01pm UTC](https://discourse.julialang.org/t/error-keyerror-key-sparsearrays-not-found/125980/12 "2025-02-19T15:01:20Z")

</div>

Thank you! That’s it! We were running CI on Windows and macOS only with Julia versions ‘min’ and ‘1’, so the earliest supported version for the package and the latest release. I now realized that ‘min’ is using 1.10.0, which doesn’t really make sense to test, so we now changed it to ‘1.10’, which solved the problem.
