Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REPLExt: no method matching repl_init(::REPL.LineEditREPL) when loading packages in REPL mode. #56216

Open
ndgnuh opened this issue Oct 17, 2024 · 29 comments · Fixed by JuliaLang/Pkg.jl#4067
Labels
bug Indicates an unexpected problem or unintended behavior regression 1.11 Regression in the 1.11 release REPL Julia's REPL (Read Eval Print Loop)

Comments

@ndgnuh
Copy link

ndgnuh commented Oct 17, 2024

Behaviour

When loading some packages in REPL, REPLExt throws an exception.

Expected behaviour

No exception thrown?

Reproduce

To reproduce:

  1. julia-release --startup-file=no -t 1
  2. using IJulia (or other packages)

Packages that reproduce the bug:

  • IJulia
  • Pluto
  • CairoMakie

Packages that don't reproduce the bug:

  • StaticArrays
  • PackageCompiler

Version info:

Julia Version 1.11.1
Commit 8f5b7ca12ad (2024-10-16 10:53 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 16 × AMD Ryzen 7 4800H with Radeon Graphics
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, znver2)
Threads: 16 default, 0 interactive, 8 GC (on 16 virtual cores)
Environment:
  JULIA_NUM_THREADS = 16
  LD_LIBRARY_LOADPATH = /opt/wine-staging/lib64:/opt/wine-staging/lib:/opt/nvim-linux64/lib:/opt/containerd/lib:
  JULIA_CUDA_USE_BINARYBUILDER = true
  JULIA_DEPOT_PATH = /home/<my-user>/.cache/julia

Stack trace

ERROR: InitError: MethodError: no method matching repl_init(::REPL.LineEditREPL)
The function `repl_init` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  repl_init(::REPL.AbstractREPL)
   @ REPLExt ~/.julia/juliaup/julia-1.11.1+0.x64.linux.gnu/share/julia/stdlib/v1.11/Pkg/ext/REPLExt/REPLExt.jl:163

Stacktrace:
  [1] __init__()
    @ REPLExt ~/.julia/juliaup/julia-1.11.1+0.x64.linux.gnu/share/julia/stdlib/v1.11/Pkg/ext/REPLExt/REPLExt.jl:305
  [2] run_module_init(mod::Module, i::Int64)
    @ Base ./loading.jl:1336
  [3] register_restored_modules(sv::Core.SimpleVector, pkg::Base.PkgId, path::String)
    @ Base ./loading.jl:1324
  [4] _include_from_serialized(pkg::Base.PkgId, path::String, ocachepath::String, depmods::Vector{Any}, ignore_native::Nothing; register::Bool)
    @ Base ./loading.jl:1213
  [5] _include_from_serialized (repeats 2 times)
    @ ./loading.jl:1169 [inlined]
  [6] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128, stalecheck::Bool; reasons::Dict{String, Int64}, DEPOT_PATH::Vector{String})
    @ Base ./loading.jl:1969
  [7] _require(pkg::Base.PkgId, env::String)
    @ Base ./loading.jl:2450
  [8] __require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:2315
  [9] #invoke_in_world#3
    @ ./essentials.jl:1089 [inlined]
 [10] invoke_in_world
    @ ./essentials.jl:1086 [inlined]
 [11] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:2302
 [12] macro expansion
    @ ./loading.jl:2241 [inlined]
 [13] macro expansion
    @ ./lock.jl:273 [inlined]
 [14] __require(into::Module, mod::Symbol)
    @ Base ./loading.jl:2198
 [15] #invoke_in_world#3
    @ ./essentials.jl:1089 [inlined]
 [16] invoke_in_world
    @ ./essentials.jl:1086 [inlined]
 [17] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:2191
during initialization of module REPLExt

Extra information

  • Loading the packages in non-interactive mode works just fine.
  • In REPL, when the exception is thrown, load the package again to make it works (v1.11.1).
@vtjnash
Copy link
Member

vtjnash commented Oct 17, 2024

This is either a duplicate of #56091 (comment) or a Pkg bug (wrongly assuming that active_repl must be assigned exactly to a REPL.AbstractREPL, while Base never made such a promise)

@Vortriz
Copy link

Vortriz commented Oct 23, 2024

I am facing the exact same issue with Plots.jl

@KristofferC
Copy link
Member

KristofferC commented Oct 23, 2024

@vtjnash, how do you add a new REPL mode right now from a package? You keep saying these are bugs but they weren't bugs until the code under it changed and caused the bugs?

@zvnkk
Copy link

zvnkk commented Oct 23, 2024

I added Depot path to move packages from c to d
and now i have this error

@zvnkk
Copy link

zvnkk commented Oct 23, 2024

So i deleted everything in new Depot path on d disk
and installed only pluto, after running using Pluto command the error is there
however when i remove $env:JULIA_DEPOT_PATH = "D:/.julia" from powershell config
and return to default c:/usr/.julia folder error goes away.
however i want to have .julia on d dist , what to do ?

@zvnkk
Copy link

zvnkk commented Oct 24, 2024

writing using Pkg in startup.jl file worked

@ndgnuh
Copy link
Author

ndgnuh commented Oct 25, 2024

So i deleted everything in new Depot path on d disk and installed only pluto, after running using Pluto command the error is there however when i remove $env:JULIA_DEPOT_PATH = "D:/.julia" from powershell config and return to default c:/usr/.julia folder error goes away. however i want to have .julia on d dist , what to do ?

I tried removing the JULIA_DEPOT_PATH. The bug indeed goes away. Therefore, reproducing this bug seems to require adding a custom JULIA_DEPOT_PATH.

@IanButterworth
Copy link
Member

IanButterworth commented Oct 30, 2024

I just hit this when using a modified version of REPL on nightly, without a custom depot, but I guess it meant REPL was precompiled to the user depot, which might be relevant.

But shouldn't repl_init(::REPL.AbstractREPL) accept LineEditREPL? It feels like we might have two different REPLs loaded..

i.e. I don't think JuliaLang/Pkg.jl#4067 fixes this..

% ./julia --start=no -ie "using REPL"
Precompiling REPL finished.
  1 dependency successfully precompiled in 22 seconds. 6 already precompiled.
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.12.0-DEV.1518 (2024-10-30)
 _/ |\__'_|_|_|\__'_|  |  Commit 599b7ec51a (0 days old master)
|__/                   |

(@v1.12) pkg> Unhandled Task ERROR: InitError: MethodError: no method matching repl_init(::LineEditREPL)
The function `repl_init` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  repl_init(::REPL.AbstractREPL)
   @ REPLExt ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.12/Pkg/ext/REPLExt/REPLExt.jl:171

Stacktrace:
  [1] __init__()
    @ REPLExt ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.12/Pkg/ext/REPLExt/REPLExt.jl:314
  [2] run_module_init(mod::Module, i::Int64)
    @ Base ./loading.jl:1418
  [3] register_restored_modules(sv::Core.SimpleVector, pkg::Base.PkgId, path::String)
    @ Base ./loading.jl:1406
  [4] _include_from_serialized(pkg::Base.PkgId, path::String, ocachepath::String, depmods::Vector{Any}, ignore_native::Nothing; register::Bool)
    @ Base ./loading.jl:1294
  [5] _include_from_serialized (repeats 2 times)
    @ ./loading.jl:1245 [inlined]
  [6] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128, stalecheck::Bool; reasons::Nothing, DEPOT_PATH::Vector{String})
    @ Base ./loading.jl:2115
  [7] _require_search_from_serialized
    @ ./loading.jl:2009 [inlined]
  [8] macro expansion
    @ ./loading.jl:2775 [inlined]
  [9] macro expansion
    @ ./lock.jl:294 [inlined]
 [10] require_stdlib(package_uuidkey::Base.PkgId, ext::String)
    @ Base ./loading.jl:2760
 [11] load_pkg
    @ ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.12/REPL/src/Pkg_beforeload.jl:4 [inlined]
 [12] (::REPL.var"#setup_interface##26#setup_interface##27"{REPL.LineEdit.MIState, LineEditREPL, REPL.LineEdit.Prompt})()
    @ REPL ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.12/REPL/src/REPL.jl:1457
during initialization of module REPLExt

@IanButterworth IanButterworth added bug Indicates an unexpected problem or unintended behavior REPL Julia's REPL (Read Eval Print Loop) regression 1.11 Regression in the 1.11 release labels Oct 30, 2024
@Andriamanitra
Copy link

I started seeing this issue after updating Julia from 1.10 to 1.11.1. In my case the package that triggers it is Plots.jl. My JULIA_DEPOT_PATH is set to ~/Packages/julia.

Julia Version 1.11.1
Commit 8f5b7ca12ad (2024-10-16 10:53 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 24 × AMD Ryzen 9 5900X 12-Core Processor
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, znver3)
Threads: 1 default, 0 interactive, 1 GC (on 24 virtual cores)
Environment:
  JULIA_DEPOT_PATH = /home/mikko/Packages/julia
Stack trace
ERROR: InitError: MethodError: no method matching repl_init(::REPL.LineEditREPL)
The function `repl_init` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  repl_init(::REPL.AbstractREPL)
   @ REPLExt ~/Packages/julia/juliaup/julia-1.11.1+0.x64.linux.gnu/share/julia/stdlib/v1.11/Pkg/ext/REPLExt/REPLExt.jl:163

Stacktrace:
  [1] __init__()
    @ REPLExt ~/Packages/julia/juliaup/julia-1.11.1+0.x64.linux.gnu/share/julia/stdlib/v1.11/Pkg/ext/REPLExt/REPLExt.jl:305
  [2] run_module_init(mod::Module, i::Int64)
    @ Base ./loading.jl:1336
  [3] register_restored_modules(sv::Core.SimpleVector, pkg::Base.PkgId, path::String)
    @ Base ./loading.jl:1324
  [4] _include_from_serialized(pkg::Base.PkgId, path::String, ocachepath::String, depmods::Vector{…}, ignore_native::Nothing; register::Bool)
    @ Base ./loading.jl:1213
  [5] _include_from_serialized (repeats 2 times)
    @ ./loading.jl:1169 [inlined]
  [6] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128, stalecheck::Bool; reasons::Dict{…}, DEPOT_PATH::Vector{…})
    @ Base ./loading.jl:1969
  [7] _require(pkg::Base.PkgId, env::String)
    @ Base ./loading.jl:2450
  [8] __require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:2315
  [9] #invoke_in_world#3
    @ ./essentials.jl:1089 [inlined]
 [10] invoke_in_world
    @ ./essentials.jl:1086 [inlined]
 [11] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:2302
 [12] macro expansion
    @ ./loading.jl:2241 [inlined]
 [13] macro expansion
    @ ./lock.jl:273 [inlined]
 [14] __require(into::Module, mod::Symbol)
    @ Base ./loading.jl:2198
 [15] #invoke_in_world#3
    @ ./essentials.jl:1089 [inlined]
 [16] invoke_in_world
    @ ./essentials.jl:1086 [inlined]
 [17] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:2191
 [18] top-level scope
    @ ~/Packages/julia/packages/Plots/kLeqV/src/backends.jl:568
 [19] eval
    @ ./boot.jl:430 [inlined]
 [20] _initialize_backend(pkg::Plots.PlotlyBackend)
    @ Plots ~/Packages/julia/packages/Plots/kLeqV/src/backends.jl:567
 [21] backend(pkg::Plots.PlotlyBackend)
    @ Plots ~/Packages/julia/packages/Plots/kLeqV/src/backends.jl:245
 [22] plotly
    @ ~/Packages/julia/packages/Plots/kLeqV/src/backends.jl:86 [inlined]
 [23] plot_standings(get_schedule::typeof(GraphicalNhlStandings.read_cached_schedule))
    @ GraphicalNhlStandings ~/coding/GraphicalNhlStandings/src/GraphicalNhlStandings.jl:120
 [24] top-level scope
    @ REPL[2]:1

@matthias314
Copy link
Contributor

matthias314 commented Nov 22, 2024

Is this supposed to be fixed in Julia 1.11.2?

I still see this error with the release-1.11 branch when loading for example TerminalPager. If I unset JULIA_DEPOT_PATH, the problem disappears.

@IanButterworth
Copy link
Member

Can you share the error message. It should at least be different.

@matthias314
Copy link
Contributor

Here it is. You are right, it's slightly different.

$ ./julia --startup=no
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.11.1 (2024-11-21)
 _/ |\__'_|_|_|\__'_|  |  release-1.11/229f027675* (fork: 527 commits, 280 days)
|__/                   |

julia> using TerminalPager
ERROR: InitError: MethodError: no method matching _init_pager_repl_mode(::REPL.LineEditREPL)
The function `_init_pager_repl_mode` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  _init_pager_repl_mode(::REPL.AbstractREPL)
   @ TerminalPager /usr/local/julia-depot/packages/TerminalPager/RRlVk/src/repl.jl:158

@IanButterworth
Copy link
Member

My guess is we have two versions of REPL loaded and it's interacting badly, but it's really unclear to me.

I also don't understand why this is happening only when you set JULIA_DEPOT_PATH

@vtjnash require_stdlib should be loading the same REPL cache file however JULIA_DEPOT_PATH is set, I believe?

@vtjnash
Copy link
Member

vtjnash commented Nov 22, 2024

You need #55908, which I believe is v1.11.2

@IanButterworth
Copy link
Member

IanButterworth commented Nov 22, 2024

The above is on the tip of release-1.11 229f027 so that's either not there or not working

@IanButterworth

This comment has been minimized.

@IanButterworth

This comment has been minimized.

@IanButterworth
Copy link
Member

It is on release-1.11 so #55908 didn't fix this.

@vtjnash
Copy link
Member

vtjnash commented Nov 22, 2024

Oh, if you also have JULIA_DEPOT_PATH that excludes stdlib, that is an explicit directive never to load the one in stdlib for the user, so this is working as expected

@vtjnash
Copy link
Member

vtjnash commented Nov 22, 2024

We have a test to make sure this does it correctly with : vs without that: (#55908 (comment))

@IanButterworth
Copy link
Member

So what's the actual reason for the failure here? If the bundled cache isn't loaded because JULIA_DEPOT_PATH is missing :, then... I don't understand.

@vtjnash
Copy link
Member

vtjnash commented Nov 22, 2024

The failure here is a failure of some packages to correctly respect the API of the Base.active_repl value. In particular, it is a private value that is unsafe to access from __init__

@matthias314
Copy link
Contributor

matthias314 commented Nov 22, 2024

In case it matters: I'm using

JULIA_DEPOT_PATH = /usr/local/julia-depot

EDIT: Another package where this problem occurs is Cthulhu, see JuliaDebug/Cthulhu.jl#608.

@IanButterworth
Copy link
Member

julia> REPL.LineEditREPL <: REPL.AbstractREPL
true

Yet

julia> using TerminalPager
ERROR: InitError: MethodError: no method matching _init_pager_repl_mode(::REPL.LineEditREPL)
The function `_init_pager_repl_mode` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  _init_pager_repl_mode(::REPL.AbstractREPL)
   @ TerminalPager /usr/local/julia-depot/packages/TerminalPager/RRlVk/src/repl.jl:158

@vtjnash
Copy link
Member

vtjnash commented Nov 22, 2024

Yes, while some names may print the same, that won't guarantee they are the same type

@vtjnash
Copy link
Member

vtjnash commented Nov 22, 2024

Once #54654 merges, that will be true even less frequently than it is now

@IanButterworth
Copy link
Member

So when there's no trailing : we get two different REPL modules loaded, and errors like this.

When JULIA_DEPOT_PATH isnt set or there's a trailing : we only get one REPL module loaded?

If so, I don't understand why that's desirable.

@vtjnash
Copy link
Member

vtjnash commented Nov 23, 2024

It is the meaning of the : is whether or not the stdlibs are supposed to be available to extended in package code. Without the : the stdlib code is not supposed to be extended as the user has taken that out of their path. However, in no case is extension supposed to occur anyways of stdlibs, as that is documented as being piracy or private

@giordano
Copy link
Contributor

Wasn't that for the load path rather than the depot path?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior regression 1.11 Regression in the 1.11 release REPL Julia's REPL (Read Eval Print Loop)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants