Debugging julia code

Yes, for the near future it’s going to be slow (kind of like Python or Lisp :wink:). You’re going to have to identify small test cases that can run quickly.

3 Likes

Wait. Can python do that? I’ve been working with python lately, but had the impression that you have to explicitly launch a debugging session. How do you accomplish this?

https://docs.python.org/3/library/pdb.html

See pdb.post_morten

Since you have to launch pdb before you run your code, how is that different from @interpret mycode(args...)?

So do you have to explicitly launch the debugger, or can you just do like Matlab, and set dbstop if error before running your code from the ordinary command line?

No need to launch it before. Just use ipython, and do %debug to debug the last exception. It works in Jupyter notebooks, too.

In [1]: "asidhaisfh".length(2)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-1-28f983e3c036> in <module>()
----> 1 "asidhaisfh".length(2)

AttributeError: 'str' object has no attribute 'length'

In [2]: %debug
> <ipython-input-1-28f983e3c036>(1)<module>()
----> 1 "asidhaisfh".length(2)

ipdb> 

If you don’t care about speed, then sure, @interpret would be just as convenient as Python.

1 Like

Sorry for reviving this topic, but when I call in Jupyter %debug I get the following message:
The Julia interactive debugger is provided by the Gallium package.
But the Gallium GitHub repo says it is deprecated and it seems that the other debuggers are not for Jupyter.

Am I missing something or is there a new recommendation for debugging in a Jupyter notebook?

1 Like

Unless the Julia Language Server integrates Debugger.jl then there is no way to debug in Jupyter. I am trying to figure this out.

Will report back.