comonicon / Comonicon.jl

Your best CLI generator in JuliaLang
https://comonicon.org
MIT License
282 stars 25 forks source link

[BUG] @cast does not work on Julia 1.11 #272

Closed jakobnissen closed 5 months ago

jakobnissen commented 5 months ago

During precompilation, I get

Precompiling project...
        Info Given BinBencher was explicitly requested, output will be shown live
ERROR: LoadError: MethodError: no method matching doc(::typeof(BinBencher.bench))
The function `doc` exists, but no method is defined for this combination of argument types.
Stacktrace:
 [1] split_docstring(f::Function)
   @ Comonicon ~/.julia/packages/Comonicon/AXDxW/src/frontend/markdown.jl:11
 [2] cast(f::Function, name::String, args::Vector{Comonicon.JLArgument}, options::Vector{Comonicon.JLOption}, flags::Vector{Comonicon.JLFlag}, line::LineNumberNode)
   @ Comonicon ~/.julia/packages/Comonicon/AXDxW/src/frontend/cast.jl:571

This happens because Comonicon uses Base.Docs.doc, whose methods are defined in REPL, which is not loaded during precompilation on 1.11 (because REPL is not loaded, as it has been moved out of the systemimage).

The solution is to declare REPL a dependency of Comonicon.

Roger-luo commented 5 months ago

for compatibility, should we declare it as a dependency for previous Julia version as well?

jakobnissen commented 5 months ago

Yes, that can be done as well - without any issues, I believe.

jakobnissen commented 5 months ago

Perhaps a better solution is to remove the use of any REPL internals. After all, a CLI interface shouldn't need a REPL, that's kind of the whole point of a CLI interface.

MilesCranmer commented 5 months ago

What's the status of this?


For anybody coming from google, my temporary workaround is to add REPL as a dependency of my project, and then do using REPL: REPL at the top of my main module.

Roger-luo commented 5 months ago

Oops I forgot to tag the fix

Roger-luo commented 5 months ago

should be fixed now.

jakobnissen commented 4 months ago

@Roger-luo I'm still having this same issue on Julia 1.11-beta1 and Comonicon 1.0.7. Are you sure it's fixed? Here is the stack trace:

ERROR: LoadError: MethodError: no method matching doc(::typeof(BinBencher.bench))
The function `doc` exists, but no method is defined for this combination of argument types.
Stacktrace:
 [1] split_docstring(f::Function)
   @ Comonicon ~/.julia/packages/Comonicon/keaqT/src/frontend/markdown.jl:11
 [2] cast(f::Function, name::String, args::Vector{Comonicon.JLArgument}, options::Vector{Comonicon.JLOption}, flags::Vector{Comonicon.JLFlag}, line::LineNumberNode)
   @ Comonicon ~/.julia/packages/Comonicon/keaqT/src/frontend/cast.jl:571
 [3] top-level scope
   @ ~/.julia/packages/Comonicon/keaqT/src/frontend/cast.jl:419
 [4] include(mod::Module, _path::String)
   @ Base ./Base.jl:558
 [5] include(x::String)
   @ BinBencher ~/code/BinBencher.jl/src/BinBencher.jl:1
 [6] top-level scope
   @ ~/code/BinBencher.jl/src/BinBencher.jl:25
 [7] include
   @ ./Base.jl:558 [inlined]

And the loaded dependencies:

(BinBencher) pkg> st
Project BinBencher v0.1.0
Status `~/code/BinBencher.jl/Project.toml`
  [63a9268e] BinBencherBackend v0.3.0 `../BinBencherBackend.jl`
  [944b1d66] CodecZlib v0.7.4
  [863f3e99] Comonicon v1.0.7
  [c2308a5c] FASTX v2.1.5
  [0f8b85d8] JSON3 v1.14.0