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

loading RCall in atreplinit fails because of RPrompt #504

Closed
schlichtanders opened this issue Oct 21, 2023 · 1 comment
Closed

loading RCall in atreplinit fails because of RPrompt #504

schlichtanders opened this issue Oct 21, 2023 · 1 comment

Comments

@schlichtanders
Copy link

starting Julia with the following startup.jl file fails:

atreplinit() do repl
    try
        @eval begin
            using CondaPkg
            ENV["R_HOME"] = CondaPkg.envdir() * "/lib/R"

            import Pkg
            Pkg.build("RCall")

            using RCall
        end
    catch e
        @error "could not initialize julia" exception=(e, catch_backtrace())
    end
end

here the error:

│   exception =
│    InitError: UndefRefError: access to undefined reference
│    Stacktrace:
│      [1] getproperty
│        @ ./Base.jl:37 [inlined]
│      [2] repl_inited(repl::REPL.LineEditREPL)
│        @ RCall.RPrompt ~/.julia/packages/RCall/gOwEW/src/RPrompt.jl:241
│      [3] __init__()
│        @ RCall ~/.julia/packages/RCall/gOwEW/src/setup.jl:213
│      [4] register_restored_modules(sv::Core.SimpleVector, pkg::Base.PkgId, path::String)
│        @ Base ./loading.jl:1115
│      [5] _include_from_serialized(pkg::Base.PkgId, path::String, ocachepath::String, depmods::Vector{Any})
│        @ Base ./loading.jl:1061
│      [6] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128)
│        @ Base ./loading.jl:1506
│      [7] _require(pkg::Base.PkgId, env::String)
│        @ Base ./loading.jl:1783
│      [8] _require_prelocked(uuidkey::Base.PkgId, env::String)
│        @ Base ./loading.jl:1660
│      [9] macro expansion
│        @ ./loading.jl:1648 [inlined]
│     [10] macro expansion
│        @ ./lock.jl:267 [inlined]
│     [11] require(into::Module, mod::Symbol)
│        @ Base ./loading.jl:1611
│     [12] top-level scope
│        @ ~/.julia/config/startup.jl:18
│     [13] eval
│        @ ./boot.jl:370 [inlined]
│     [14] (::var"#3#5")(repl::REPL.LineEditREPL)
│        @ Main ~/.julia/config/startup.jl:9
│     [15] __atreplinit(repl::REPL.LineEditREPL)
│        @ Base ./client.jl:372
│     [16] #invokelatest#2
│        @ ./essentials.jl:819 [inlined]
│     [17] invokelatest
│        @ ./essentials.jl:816 [inlined]
│     [18] _atreplinit
│        @ ./client.jl:379 [inlined]
│     [19] (::Base.var"#1017#1019"{Bool, Bool, Bool})(REPL::Module)
│        @ Base ./client.jl:420
│     [20] #invokelatest#2
│        @ ./essentials.jl:819 [inlined]
│     [21] invokelatest
│        @ ./essentials.jl:816 [inlined]
│     [22] run_main_repl(interactive::Bool, quiet::Bool, banner::Bool, history_file::Bool, color_set::Bool)
│        @ Base ./client.jl:405
│     [23] exec_options(opts::Base.JLOptions)
│        @ Base ./client.jl:322
│     [24] _start()
│        @ Base ./client.jl:522
│    during initialization of module RCall
└ @ Main ~/.julia/config/startup.jl:31
@schlichtanders
Copy link
Author

Workaround

you apparently can use atreplinit() as follows

import REPL
atreplinit() do repl
    try
        # interface is needed for importing RCall
        repl.interface = REPL.setup_interface(repl)
...

and it works

@palday palday closed this as completed Jul 17, 2024
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

2 participants