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

REPL modes do not work after compilation #68

Closed
diegozea opened this issue May 14, 2018 · 12 comments
Closed

REPL modes do not work after compilation #68

diegozea opened this issue May 14, 2018 · 12 comments

Comments

@diegozea
Copy link

REPL modes from IPython and Rcall don't work after the packages are compiled with the stable version of PackageCompiler (0.3.1). For example:

# compilation
using PackageCompiler
compile_package("RCall", force = false, reuse = false) 
# using the new image
~$ julia -J /home/zea/.julia/v0.6/PackageCompiler/sysimg/sys.so

RCall (compiled) REPL mode doesn't work, $ should show the R> prompt:
image

P.S.: Also, I get a lot of WARNING: redefining constant JULIA_HOME messages using the compiled image.

@SimonDanisch
Copy link
Collaborator

I wonder if that's expected, since they're fairly dynamic. @KristofferC, you should know REPL modes pretty well, any ideas?

@KristofferC
Copy link
Sponsor Member

In Pkg3, we set up the REPL as https://github.com/JuliaLang/Pkg3.jl/blob/bd3802f3738c834f44ccb2d354b2befb0cea4234/src/Pkg3.jl#L55-L66 in __init__. Not sure how RCall does it.

@diegozea
Copy link
Author

I think @randy3k will have a better idea of how RCall does it.

@randy3k
Copy link

randy3k commented May 14, 2018

RCall uses this to setup the REPL, I got the idea from @Keno's Cxx.jl, so I assume I was correct...

@randy3k
Copy link

randy3k commented May 14, 2018

@diegozea how about initializing the REPL manually?

RCall.RPrompt.repl_init(Base.active_repl)

@KristofferC
Copy link
Sponsor Member

I think you need to handle the case when the REPL is not yet inited but the package gets loaded.

@randy3k
Copy link

randy3k commented May 14, 2018

Is there any hook we could use to load the repl code when the repl is ready?

@tkf
Copy link
Member

tkf commented Nov 2, 2018

@diegozea I think I solved it in IPython.jl master.

@KristofferC It would be nice if Base has afterreplinit (or something) to wrap what Pkg.jl is doing:

"""
    afterreplinit(f)

Like `atreplinit` but triggers `f` even after REPL is initialized when
it is called.  For `LineEditREPL`, it ensures that `interface` is
initialized.
"""
function afterreplinit(f)
    if isdefined(Base, :active_repl)
        f(Base.active_repl)
    else
        atreplinit() do repl
            if isinteractive() && repl isa REPL.LineEditREPL
                isdefined(repl, :interface) || (repl.interface = REPL.setup_interface(repl))
                f(repl)
            end
        end
    end
end

@KristofferC
Copy link
Sponsor Member

Not a PackageCompiler bug, the package needs to be more robust in how the REPL is started like described in #68 (comment)

@tkf
Copy link
Member

tkf commented Feb 11, 2020

Can julia runtime help individual packages to solve this problem? I think the way Pkg "solving" this touches too much implementation details of the julia runtime (including the REPL stdlib). I think we need an appropriate hook to cleanly solve this: JuliaLang/julia#29896

@KristofferC
Copy link
Sponsor Member

Yes, Julia could very well facilitate this. Point here is that it isn't a PackageCompiler issue.

@tkf
Copy link
Member

tkf commented Feb 11, 2020

I was commenting just because I was worried that #68 (comment) would be regarded as the official correct solution. I am glad that you acknowledge that there can be a better solution.

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

5 participants