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

"UndefRefError: access to undefined reference" in 1.11 beta #345

Open
numbermaniac opened this issue Apr 11, 2024 · 11 comments
Open

"UndefRefError: access to undefined reference" in 1.11 beta #345

numbermaniac opened this issue Apr 11, 2024 · 11 comments

Comments

@numbermaniac
Copy link

Following the installation guide, I have this in my startup.jl file:

atreplinit() do repl
    try
        @eval using OhMyREPL
    catch e
        @warn "error while importing OhMyREPL" e
    end
end

In Julia 1.11 beta 1, I see the following message when starting a repl now:

┌ Warning: error while importing OhMyREPL
│   e =
│    InitError: UndefRefError: access to undefined reference
│    during initialization of module REPLExt
└ @ Main ~/.julia/config/startup.jl:5

I didn't see this message in 1.10, so I'm guessing it's something to do with 1.11 specifically. The error message means that none of the syntax highlighting works.

Interestingly if I do using OhMyREPL after the repl has started up, then there are no import errors and all syntax highlighting works. So it seems like something is broken here.

@osimonn
Copy link

osimonn commented May 7, 2024

I tried slimming down my startup.jl file to just using OhMyREPL but I get the following error when entering Pkg mode and try to add a package:

(@v1.11) pkg> add ┌ Error: Error in the keymap
│   exception =
│    IOError: stat("DriverState\\\\"): permission denied (EACCES)
│    Stacktrace:
│      [1] uv_error
│        @ .\libuv.jl:106 [inlined]
│      [2] stat(path::String)
│        @ Base.Filesystem .\stat.jl:176
│      [3] isdir
│        @ .\stat.jl:494 [inlined]
│      [4] (::REPLExt.var"#2#5"{String, Int64, UnitRange{Int64}})(x::String)
│        @ REPLExt C:\Users\eamsmao\.julia\juliaup\julia-1.11.0-beta1+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Pkg\ext\REPLExt\completions.jl:40
│      [5] filter!(f::REPLExt.var"#2#5"{String, Int64, UnitRange{Int64}}, a::Vector{String})
│        @ Base .\array.jl:2912
│      [6] complete_expanded_local_dir(s::String, i1::Int64, i2::Int64, expanded_user::Bool, oldi2::Int64)
│        @ REPLExt C:\Users\eamsmao\.julia\juliaup\julia-1.11.0-beta1+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Pkg\ext\REPLExt\completions.jl:40
│      [7] complete_local_dir(s::String, i1::Int64, i2::Int64)
│        @ REPLExt C:\Users\eamsmao\.julia\juliaup\julia-1.11.0-beta1+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Pkg\ext\REPLExt\completions.jl:33
│      [8] complete_add_dev(options::Dict{Symbol, Any}, partial::String, i1::Int64, i2::Int64)
│        @ REPLExt C:\Users\eamsmao\.julia\juliaup\julia-1.11.0-beta1+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Pkg\ext\REPLExt\completions.jl:140
│      [9] (::Pkg.REPLMode.var"#33#34"{Symbol})(opts::Dict{Symbol, Any}, partial::String, offset::Int64, index::Int64)
│        @ Pkg.REPLMode C:\Users\eamsmao\.julia\juliaup\julia-1.11.0-beta1+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Pkg\src\REPLMode\command_declarations.jl:8
│     [10] complete_argument(spec::Pkg.REPLMode.CommandSpec, options::Vector{String}, partial::String, offset::Int64, index::Int64)
│        @ REPLExt C:\Users\eamsmao\.julia\juliaup\julia-1.11.0-beta1+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Pkg\ext\REPLExt\completions.jl:190
│     [11] _completions(input::String, final::Bool, offset::Int64, index::Int64)
│        @ REPLExt C:\Users\eamsmao\.julia\juliaup\julia-1.11.0-beta1+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Pkg\ext\REPLExt\completions.jl:216
│     [12] completions(full::String, index::Int64)
│        @ REPLExt C:\Users\eamsmao\.julia\juliaup\julia-1.11.0-beta1+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Pkg\ext\REPLExt\completions.jl:247
│     [13] complete_line(c::REPLExt.PkgCompletionProvider, s::REPL.LineEdit.PromptState)
│        @ REPLExt C:\Users\eamsmao\.julia\juliaup\julia-1.11.0-beta1+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Pkg\ext\REPLExt\REPLExt.jl:29
│     [14] complete_line(c::REPL.LineEdit.CompletionProvider, s::Any, ::Module)
│        @ REPL.LineEdit C:\Users\eamsmao\.julia\juliaup\julia-1.11.0-beta1+0.x64.w64.mingw32\share\julia\stdlib\v1.11\REPL\src\LineEdit.jl:187
│     [15] check_for_hint(s::REPL.LineEdit.MIState)
│        @ REPL.LineEdit C:\Users\eamsmao\.julia\juliaup\julia-1.11.0-beta1+0.x64.w64.mingw32\share\julia\stdlib\v1.11\REPL\src\LineEdit.jl:384
│     [16] (::REPL.LineEdit.var"#139#195")(s::REPL.LineEdit.MIState, data::Any, c::Union{Char, SubString{String}, String})
│        @ REPL.LineEdit C:\Users\eamsmao\.julia\juliaup\julia-1.11.0-beta1+0.x64.w64.mingw32\share\julia\stdlib\v1.11\REPL\src\LineEdit.jl:2520
│     [17] #invokelatest#2
│        @ .\essentials.jl:1030 [inlined]
│     [18] invokelatest
│        @ .\essentials.jl:1027 [inlined]
│     [19] (::REPL.LineEdit.var"#27#28"{REPL.LineEdit.var"#139#195", String})(s::Any, p::Any)
│        @ REPL.LineEdit C:\Users\eamsmao\.julia\juliaup\julia-1.11.0-beta1+0.x64.w64.mingw32\share\julia\stdlib\v1.11\REPL\src\LineEdit.jl:1704
│     [20] prompt!(term::REPL.Terminals.TextTerminal, prompt::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
│        @ REPL.LineEdit C:\Users\eamsmao\.julia\juliaup\julia-1.11.0-beta1+0.x64.w64.mingw32\share\julia\stdlib\v1.11\REPL\src\LineEdit.jl:2841
│     [21] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
│        @ REPL.LineEdit C:\Users\eamsmao\.julia\juliaup\julia-1.11.0-beta1+0.x64.w64.mingw32\share\julia\stdlib\v1.11\REPL\src\LineEdit.jl:2743
│     [22] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
│        @ REPL C:\Users\eamsmao\.julia\juliaup\julia-1.11.0-beta1+0.x64.w64.mingw32\share\julia\stdlib\v1.11\REPL\src\REPL.jl:1407
│     [23] (::REPL.var"#75#81"{REPL.LineEditREPL, REPL.REPLBackendRef})()
│        @ REPL C:\Users\eamsmao\.julia\juliaup\julia-1.11.0-beta1+0.x64.w64.mingw32\share\julia\stdlib\v1.11\REPL\src\REPL.jl:457
└ @ REPL.LineEdit C:\Users\eamsmao\.julia\juliaup\julia-1.11.0-beta1+0.x64.w64.mingw32\share\julia\stdlib\v1.11\REPL\src\LineEdit.jl:2843

I am not sure if this error is related to this issue.
Here is my setup:

julia> versioninfo()
Julia Version 1.11.0-beta1
Commit 08e1fc0abb (2024-04-10 08:40 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 8 × 11th Gen Intel(R) Core(TM) i5-1145G7 @ 2.60GHz
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, tigerlake)
Threads: 8 default, 0 interactive, 4 GC (on 8 virtual cores)
Environment:
  JULIA_NUM_THREADS = auto

@numbermaniac
Copy link
Author

Another thing I noticed is that, if I do @eval using OhMyREPL a second time to make it work (as mentioned in my first comment), it breaks the ability to hit ] to enter the Pkg REPL. Instead, it just types a ] into the Julia REPL now.

The bug is also present in 1.11.0-rc1.

@huangyxi
Copy link
Contributor

huangyxi commented Jul 4, 2024

Take a try:

# ~/.julia/config/juliaup.jl
if isinteractive()
	try
		using OhMyREPL
	catch
	end
end

@KristofferC
Copy link
Owner

I think this has to do with Pkg moving out of the sysimage, this part of the code should maybe move to an extension.

@jlapeyre
Copy link

jlapeyre commented Oct 7, 2024

I find no error and that OhMyREPL works properly if I load Pkg first. For example:

using Pkg: Pkg
atreplinit() do repl
    try
        @eval using OhMyREPL
    catch e
        @warn "error while importing OhMyREPL" e
    end
end

Version 1.11.0-rc3 and nightly,
@numbermaniac , @osimonn

@dpo
Copy link

dpo commented Oct 19, 2024

This isn’t only an issue with OhMyREPL. I have the same with InteractiveCodeSearch.

@cena
Copy link

cena commented Nov 22, 2024

Error persists with 1.11.1 (2024-10-16), works with @jlapeyre 's using Pkg: Pkg addition to startup.jl.

@cena
Copy link

cena commented Nov 22, 2024

Just another data point:

Warning with 1.12-DEV.1680:

SCR-20241122-nlox
┌ Warning: error while importing OhMyREPL
│   e =
│    ArgumentError: Package OhMyREPL not found in current path.
│    - Run `import Pkg; Pkg.add("OhMyREPL")` to install the OhMyREPL package.
└ @ Main ~/.julia/config/startup.jl:6

Adding import Pkg; Pkg.add("OhMyREPL") to startup.jl (and removing 'using Pkg: Pkg') works on both this version and 1.11.1.

@jlapeyre
Copy link

jlapeyre commented Nov 22, 2024

My recollection is that I found OhMyREPL was using something in an extension in Pkg. Maybe it was moved out of Pkg and into an extension, and any package that depended on that something being there would break.

@jlapeyre
Copy link

Adding import Pkg; Pkg.add("OhMyREPL") to startup.jl (and removing 'using Pkg: Pkg') works on both this version and 1.11.1.

Looks like you might be confused about the message. If you started 1.12 for the first time, OhMyREPL would not be in your default environment. Doing import Pkg; Pkg.add("OhMyREPL") just once is enough to take care of it. This doesn't belong in your startup.jl.

For practical purposes, using Pkg: Pkg and import Pkg are doing the same thing. After having installed OhMyREPL (once), either one will do.

@cena
Copy link

cena commented Nov 25, 2024

Ah! @jlapeyre - thank you for your correction of this hapless newbie - the kindness + education is much appreciated. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants