Using Debugger in Julia 1.6.3

I am having difficulties using Debugger in Julia 1.6.3. I attempted to run the simple example from Debugger at github and if failed. Can someone suggest what I am doing wrong or a work-around. I do have vscode working, but having to stop and start it every time I change a struct is making code development slow. Thanks.

julia> using Pkg;Pkg.add("Debugger")
julia> function foo(n)
           x = n+1
           ((BigInt[1 1; 1 0])^x)[2,1]
       end
foo (generic function with 1 method)

julia> @enter foo(20)
ERROR: LoadError: UndefVarError: @enter not defined
in expression starting at REPL[25]:1

You need to load Debugger

Julia> using Debugger
1 Like

Sorry, my apologies; however:


julia> function foo(n)
           x = n+1
           ((BigInt[1 1; 1 0])^x)[2,1]
       end
foo (generic function with 1 method)

julia> @enter foo(20)
In foo(n) at REPL[45]:1
 1  function foo(n)
>2      x = n+1
 3      ((BigInt[1 1; 1 0])^x)[2,1]
 4  end

About to run: (+)(20, 1)
1|debug> n
ERROR: UndefVarError: _apply_latest not defined
Stacktrace:
 [1] +(x::Int64, y::Int64)
   @ Base int.jl:87
 [2] foo(n::Int64)
   @ Main REPL[45]:2

julia>

There’s something wrong with your code formatting. Can you put the code inside triple backticks? Now it literally says “blockquote”, which is very odd.

Here’s an explanation how to format your code Please read: make it easier to help you

Just tried the example, worked for me.

Thank you, I requested help on this in “Getting Started”. I will read your suggested link immediately after this reply.

I’m doing something incorrect, but I don’t know what. I just recently downloaded 1.6.3 and am only running the example from the github readme.md. I’m running Ubuntu 20.04 on an old desktop.

Linux home-ubuntu 5.11.0-38-generic #42~20.04.1-Ubuntu SMP Tue Sep 28 20:41:07 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
> 

If you have any suggestions on how to debug, I will give them a try. I really want to get Debugger working. Thanks.
p.s. I have been away from julia for a year, but have now decided to use it more (because it’s so much faster than Python).

Where did you get Julia from? Did you download the official binaries?

How’s VS Code any different here from the REPL?

You can edit your previous posts and fix the formatting.

2 Likes

Yes, julia-1.6.3-linux-x86_64.tar.gz from julialang.org

Repl with Debugging should be much faster to try alternatives when developing code. VSCode (well code on ubuntu) is very slow to start up each time you make a change. Also, different functionality. My preference is to run both in parallel, and to use cut and paste with an external editor (for me sublime-text) and at any particular time to use what is most efficient. I expect everyone has their own methodology they get used to.

It might be an Ubuntu issue; I have tried the Debugger example on a couple of Ubuntu 12.04 machines and I get the same failure issue. Unfortuantely, I am too inexperienced with Julia to figure out how to debug it, especially with Debugger not working for me. I expect I am doing something simple incorrecly, but don’t know what it is.

I run both stable (1.6.3) and RC (1.7) Julia on 2 Ubuntu machines (18.04 and 20.04), so this should work. Can you try again on a clean environment (i.e. not the global one) and see if that works?

1 Like

I don’t understand what a clean environment or what the global environment is. Does this mean just start a new repl? Or does it have to do with environment variables in the linux shell?

If I try it in a none-project directory, it works; trying in my project directory fails:

1|debug> n
ERROR: UndefVarError: _apply_latest not defined
Stacktrace:
 [1] +(x::Int64, y::Int64)
   @ Base int.jl:87
 [2] foo(n::Int64)
   @ Main REPL[3]:2

More information: the only change made was to upgrade to 1.7.1 and now Debugger seems to be working in Ubuntu 20.04