Gallium.jl icon indicating copy to clipboard operation
Gallium.jl copied to clipboard

Does not work when called in file (not directly in REPL)

Open essenciary opened this issue 8 years ago • 3 comments

When doing julia -L the_file.jl if within the file I attempt Gallium.breakpoint(function_name) it crashes with UndefVarError(:active_repl)

essenciary avatar Oct 13 '16 12:10 essenciary

The same exception rises when called "breakpointed" function from within Juno. More specifically: "in RunDebugREPL at ASTInterperter\src\ASTInterpreter.jl:1565".

This happens on Windows platform, Julia version is

Julia Version 0.5.0 Commit 3c9d753 (2016-09-19 18:14 UTC)

Gallium version is 0.0.4 ASTInterpreter version is 0.0.4

DatName avatar Oct 31 '16 10:10 DatName

I have the same problem and a helpful comment on StackOverflow pointed me here. I do research in Julia with literate analysis: text, code, and results live in the same document, and the results in sync with the code (similar to R-markdown, e.g. in RStudio). I can have the files in either Emacs Org-mode with Org-babel or in Jupyter with IJulia. I tried Gallium and it works well in a shell session, but not in Emacs or Jupyter. In both cases I get:

ERROR: UndefVarError: active_repl not defined
Stacktrace:
 [1] RunDebugger(::Array{ASTInterpreter2.JuliaStackFrame,1}) at ~/.julia/v0.6/DebuggerFramework/src/DebuggerFramework.jl:238

mm3509 avatar Jun 07 '18 11:06 mm3509

I ran into the same issue on Julia 0.6.2 and Gallium 0.1.0. I found that I could resolve the issue by adding code from https://github.com/Keno/Arsenic.jl/blob/master/bin/attach.jl to the program

if !isdefined(Base, :active_repl)
    term = Base.Terminals.TTYTerminal(get(ENV, "TERM", @static is_windows() ? "" : "dumb"), STDIN, STDOUT, STDERR)
     active_repl = Base.REPL.LineEditREPL(term, true)
     eval(Base,:(active_repl = $active_repl))
     eval(Base,:(have_color = true))
     eval(Base,:(is_interactive = true))
end

It's a hack but it seems to work and given that no one has looked at this in over 2 years it is probably the best anyone is likely to get.

dgenin avatar Dec 07 '18 19:12 dgenin