How to fix "ERROR: LoadError: ArgumentError: Package X does not have Y in its dependencies:..." when developing package

I am trying to create a new PR for a package (Catalyst) that adds a dependency (MetaGraphs). I run ]dev Catalyst, and add some code under “.julia/dev/Catalyst/src”, this includes using MetaGraphs.

I then create a new julia Script in a new environment (ensuring that the output from
]status
includes
[479239e8] Catalyst v12.3.0~/.julia/dev/Catalyst`

I then try using Catalyst, but get an error:

[ Info: Precompiling Catalyst [479239e8-5488-4da2-87a7-35f2df7eef83]
ERROR: LoadError: ArgumentError: Package Catalyst does not have MetaGraphs in its dependencies:
- You may have a partially installed environment. Try `Pkg.instantiate()`
  to ensure all packages in the environment are installed.
- Or, if you have Catalyst checked out for development and have
  added MetaGraphs as a dependency but haven't updated your primary
  environment's manifest file, try `Pkg.resolve()`.
- Otherwise you may need to report an issue with Catalyst
Stacktrace:
 [1] macro expansion
   @ ./loading.jl:1167 [inlined]
 [2] macro expansion
   @ ./lock.jl:223 [inlined]
 [3] require(into::Module, mod::Symbol)
   @ Base ./loading.jl:1144
 [4] include
   @ ./Base.jl:419 [inlined]
 [5] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String)
   @ Base ./loading.jl:1554
 [6] top-level scope
   @ stdin:1
in expression starting at /home/SLCU/user/.julia/dev/Catalyst/src/Catalyst.jl:1
in expression starting at stdin:1
ERROR: Failed to precompile Catalyst [479239e8-5488-4da2-87a7-35f2df7eef83] to /home/SLCU/user/.julia/compiled/v1.8/Catalyst/jl_Vm90Lm.

How do I fix this?

I tried adding

MetaGraphs = "626554b9-1ddb-594c-aa3c-2596fe9399a5"

and

MetaGraphs = "0.7.1"

in Catalyst’s Project.toml file (didn’t work). I also tried to

]activate /.julia/dev/Catalyst
]add MetaGraphs

but this didn’t work either, and now I am unsure what to do.

That is the correct thing to do.

Did you do this after adding the Metagraphs dependency?

1 Like

I tried running

]resolve

both having activated the Catalyst environment and the environment where I run the using Catalyst command, but neither worked.

For reference, here is a full workflow:

(Spatial CRN Modelling) pkg> activate ../.julia/dev/Catalyst/
  Activating project at `~/Desktop/.julia/dev/Catalyst`

(Catalyst) pkg> add MetaGraphs, GraphRecipes
    Updating registry at `~/.julia/registries/General.toml`
   Resolving package versions...
  No Changes to `~/Desktop/.julia/dev/Catalyst/Project.toml`
  No Changes to `~/Desktop/.julia/dev/Catalyst/Manifest.toml`

(Catalyst) pkg> resolve
  No Changes to `~/Desktop/.julia/dev/Catalyst/Project.toml`
  No Changes to `~/Desktop/.julia/dev/Catalyst/Manifest.toml`

(Catalyst) pkg> activate .
  Activating project at `~/Desktop/Spatial CRN Modelling`

julia> using Catalyst
[ Info: Precompiling Catalyst [479239e8-5488-4da2-87a7-35f2df7eef83]
ERROR: LoadError: ArgumentError: Package Catalyst does not have MetaGraphs in its dependencies:
- You may have a partially installed environment. Try `Pkg.instantiate()`
  to ensure all packages in the environment are installed.
- Or, if you have Catalyst checked out for development and have
  added MetaGraphs as a dependency but haven't updated your primary
  environment's manifest file, try `Pkg.resolve()`.
- Otherwise you may need to report an issue with Catalyst

Resolve must be done in the environment where you do using.

This workflow does what I expect should happen:

$ mkdir /tmp/testenv
$ julia
(@v1.7) pkg> activate /tmp/testenv
(testenv) pkg> dev --local Catalyst
(testenv) pkg> activate Catalyst
(Catalyst) pkg> add MetaGraphs
(Catalyst) pkg> activate /tmp/testenv
(testenv) pkg> st -m
# Does not list MetaGraphs
(testenv) pkg> resolve
#  No Changes to `/tmp/testenv/Project.toml`
#    Updating `/tmp/testenv/Manifest.toml`
#  [5789e2e9] + FileIO v1.15.0
#  [033835bb] + JLD2 v0.4.23
#  [626554b9] + MetaGraphs v0.7.1
#  [3bb67fe8] + TranscodingStreams v0.9.9
(testenv) pkg> st -m
# Does list MetaGraphs
1 Like

This seems to work, ish, in that MetaGraphs is now listed.

However, I seem to be having another version of Catalyst than what is in my .julia/dev/Catalyst folder. E.g. I check .julia/dev/Catalyst/Project.toml and there is no sign of MetaGraphs. Furthermore, new functions that I added under .julia/dev/Catalyst/Project.toml I cannot reach through using Catalyst.

Does this approach really work to update the Catalyst version I am working on a PR for?

I opened a new (ubuntu terminal, was in VSCode before), navigated to the Catalyst directory so that I could do

julia
]activate .
]add MetaGraphs

I then restarted the VSCode session and it worked.

Thanks a lot for the help!