Error: MethodError: no method matching validate

Hi! I’m new to Julia and Catalyst.jl. I am trying to follow the tutorial of Introduction to learn how to use catalyst. I install packages, including

Blockquote
Status C:\Users\23954749\.julia\environments\v1.10\Project.toml
⌃ [479239e8] Catalyst v12.1.1
⌃ [0c46a032] DifferentialEquations v6.20.0
[f80590ac] JuliaFEM v0.5.1
⌅ [98e50ef6] JuliaFormatter v0.15.11
⌅ [961ee093] ModelingToolkit v6.4.9
[2774e3e8] NLsolve v4.5.1
⌅ [1dea7af3] OrdinaryDiffEq v5.71.2
[91a5bcdd] Plots v1.40.9
⌅ [47a9eef4] SparseDiffTools v1.21.0
[24249f21] SymPy v2.2.1
Info Packages marked with ⌃ and ⌅ have new versions available. Those with ⌃ may be upgradable, but those with ⌅ are restricted by compatibility constraints from upgrading. To see why use status --outdated

I directly copied the codes in tutorial of constructing the reaction network, as shown below,

Blockquote
using Catalyst
using OrdinaryDiffEq
using Plots
rn = @reaction_network begin
b, 0 → X
d, X → 0
end

Julia returned errors that I can’t solve, which I hope to get helped so I can keep going on.

Blockquote
ERROR: MethodError: no method matching validate(::ReactionSystem{Nothing, Catalyst.NetworkProperties{Int64, Term{Real, Base.ImmutableDict{DataType, Any}}}})

Closest candidates are:
validate(::Equation; info)
@ ModelingToolkit C:\Users\23954749.julia\packages\ModelingToolkit\0dKHa\src\systems\validation.jl:185
validate(::Equation, ::Union{Num, SymbolicUtils.Symbolic, Unitful.Quantity}; info)
@ ModelingToolkit C:\Users\23954749.julia\packages\ModelingToolkit\0dKHa\src\systems\validation.jl:186
validate(::Equation, ::Vector; info)
@ ModelingToolkit C:\Users\23954749.julia\packages\ModelingToolkit\0dKHa\src\systems\validation.jl:187

Stacktrace:
[1] ReactionSystem(eqs::Vector{…}, iv::Sym{…}, states::Vector{…}, ps::Vector{…}, var_to_name::Dict{…}, observed::Vector{…}, name::Symbol, systems::Vector{…}, defaults::Dict{…}, connection_type::Nothing, csys::Nothing, nps::Catalyst.NetworkProperties{…}, cls::Bool; checks::Bool)
@ Catalyst C:\Users\23954749.julia\packages\Catalyst\JocXA\src\reactionsystem.jl:460
[2] ReactionSystem(eqs::Vector{…}, iv::Sym{…}, states::Vector{…}, ps::Vector{…}; observed::Vector{…}, systems::Vector{…}, name::Symbol, default_u0::Dict{…}, default_p::Dict{…}, defaults::Dict{…}, connection_type::Nothing, checks::Bool, constraints::Nothing, networkproperties::Nothing, combinatoric_ratelaws::Bool, balanced_bc_check::Bool)
@ Catalyst C:\Users\23954749.julia\packages\Catalyst\JocXA\src\reactionsystem.jl:547
[3] make_ReactionSystem_internal(rxs::Vector{…}, iv::Num, no_sps::Nothing, ps_in::Vector{…}; kwargs::@Kwargs{…})
@ Catalyst C:\Users\23954749.julia\packages\Catalyst\JocXA\src\reactionsystem.jl:597
[4] top-level scope
@ C:\Users\23954749.julia\packages\Catalyst\JocXA\src\reaction_network.jl:282

Thank you!

I have been reading the other similar questions in Julia Forum. Their ‘error: no method matching’ is often relevant to the specific function or expression in their codes. That came to my blindside: I didn’t call ‘validate’ function, which I assume should be embedded in the package or somewhere that the experienced developers did. I don’t know if this could be a stupid question, but I would really appreciate it if somebody could help me out. Thanks!

You are on Catalyst v12 which is at this point two and a half years old, while the current release is 14.4.1.

Make sure you either read the documentation for v12, or update to v14 if you’re reading the latest docs.

1 Like

Yes! I noticed and I tried both documentations of catalyst v12 and v14. They returned the same error. I’m using VS Code for Julia. I don’t know if that could be the problem, such as missing packages to support catalyst.jl.

I’m not sure where in the docs you get your example from, but in any event here’s what I get on Julia 1.11.1:

(jl_hXzRfb) pkg> st
Status `(...)\Temp\jl_hXzRfb\Project.toml`
  [479239e8] Catalyst v14.4.1
  [1dea7af3] OrdinaryDiffEq v6.90.1

julia> using Catalyst, OrdinaryDiffEq

julia> rn = @reaction_network begin
       b, 0 --> X
       d, X --> 0
       end
Model ##ReactionSystem#250:
Unknowns (1): see unknowns(##ReactionSystem#250)
  X(t)
Parameters (2): see parameters(##ReactionSystem#250)
  b
  d

Problem solved~! After reading your comment, I am pretty sure something should go wrong with my Julia. So I uninstalled Julia and deleted all folders, and I re-installed Julia and catalyst. Everything worked out! I guess this problem could be the conflict of my tons of packages.
Such a long day! feels like an ambitious man stumbled down in his first step out because he is too equipped. :joy:

1 Like

This is very likely, make sure to do your work in minimal project specific environments containing only the packages you really need for the task at hand:

1 Like

I will delete this question in 3 days. Thank you for the community! If any newbies met similar problems like I did. Just re-install Julia and Catalyst~ :innocent:

No need to delete - you never know who might stumble upon this and find it helpful in future.

3 Likes

You are right! I hope my experience could help the other new users of Julia! Thank you Nilshg! :smiling_face_with_three_hearts:

1 Like