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

Getting started with RealGUD and ipdb #96

Closed
amelio-vazquez-reina opened this issue May 29, 2016 · 14 comments
Closed

Getting started with RealGUD and ipdb #96

amelio-vazquez-reina opened this issue May 29, 2016 · 14 comments
Labels

Comments

@amelio-vazquez-reina
Copy link
Contributor

amelio-vazquez-reina commented May 29, 2016

I installed RealGUD through MELPA and then followed these steps:

  1. M-x load-library realgud
  2. Then, on a Python buffer, I run M-x realgud:ipdb

The last step above prompts me with:

Run ipdb (like this): ipdb <path_to_python_file>

If I then do RET, I get:

(file-error "Searching for program" "No such file or directory" "ipdb")

I don't have ipdb in my PATH (I do have the latest IPython, Python, etc). I am not sure there is supposed to be a binary for ipdb (is it?)

Am I following these steps properly?

@rocky
Copy link
Collaborator

rocky commented May 29, 2016

When it says Run ipdb (like this): the part after that is the command you would run from a command line. For example it might be: run -d my_script from your other question.

@rocky rocky closed this as completed May 29, 2016
@amelio-vazquez-reina
Copy link
Contributor Author

amelio-vazquez-reina commented May 29, 2016

Thanks @rocky . run -d is actually a command that you run from within IPython.

Seeing your point, I tried entering the following command on the prompt that i get from M-x realgud:ipdb:

/Users/amelio/anaconda/bin/ipython -c "%run -d /Users/amelio/code/python_tests/quick_example.py"

but I end up with:

  File "<ipython-input-1-6a8e051bcd87>", line 1
    Users(/amelio/code/python_tests/%run, -d, /Users/amelio/code/python_tests/quick_example.py)
          ^
SyntaxError: invalid syntax

However, if I run that same command (i.e. /Users/amelio/anaconda/bin/ipython -c "%run -d /Users/amelio/code/python_tests/quick_example.py") from the command line (i.e. outside of Emacs), it works like a charm. Not sure what I am missing here.

@rocky
Copy link
Collaborator

rocky commented May 29, 2016

realgud parses your debugger command invocation and it's messing up badly here. And admittedly this is kind of tough situation to parse.

So why not just create a shell script and call it ipdb:

#!/bin/bash
/Users/amelio/anaconda/bin/ipython -c "%run -d $@"

and then when it prompts for a command that starts ipdb you have something easy to give it.

The other thing I do, is just start inside a shell and then run realgud-track-mode

@amelio-vazquez-reina
Copy link
Contributor Author

Thanks. That worked great! 👍 I added the script to PATH and now everything works well.

For anyone using IPython, I found the combination of RealGUD with isend-mode](https://github.com/ffevotte/isend-mode.el) really useful:

  • RealGUD: For debugging
  • isend-mode: To send code from any buffer to an interpreter running on any buffer

The latter is helpful to grow code organically (i.e. run the debugger until you reach the portion of the code that you are working on, and then use isend-mode to test any new code on the REPL)

@rocky
Copy link
Collaborator

rocky commented May 29, 2016

Glad you got this working. I don't know that much about ipdb.

For anyone using IPython, ...

Why not add a page to the wiki with your suggestions? That way others will be able to learn from your wisdom. Thanks.

@cactail
Copy link

cactail commented Jul 1, 2016

Hi everyone...
I did exactly every step that you suggested. I did make the script and runs well on terminal also if I import pdb with pdb.set_trace() runs ipdb.
But from realgud, with:

M-x realgud:ipdb [RET]
Run ipdb (like this): ipdb /home/cactus/Dev/ownlibrary/play.py

Then

Current directory: /home/cactus/Dev/ownlibrary/
Command: ipdb /home/cactus/Dev/ownlibrary/play.py
(file-error "Searching for program" "no existe el fichero o el directorio" "ipdb")
Failed to invoke debugger ipdb on program ipdb with args /home/cactus/Dev/ownlibrary/play.py

Sorry for post here, I should put a question on Emacs StackExchange??

@rocky
Copy link
Collaborator

rocky commented Jul 1, 2016

The message says that GNU emacs can't find ipdb. What happens if you give an explicit path to whereever ipdb is located.

For example suppose it is in /usr/local/bin/ipdb. Then

M-x realgud:ipdb [RET]
Run ipdb (like this): /usr/local/bin/ipdb /home/cactus/Dev/ownlibrary/play.py

@cactail
Copy link

cactail commented Jul 1, 2016

Works! Great, thanks for the answer. Open a new buffer called ipdb script.py shell.
Why? Someway to used only
Run ipdb (like this): ipdb some_file.py?

@rocky
Copy link
Collaborator

rocky commented Jul 2, 2016

Since you can have several ipdb debugging sessions, buffers have to have somewhat unique names.

I don't know if this answers your question, because I don't understand your question or concern.

@cactail
Copy link

cactail commented Jul 2, 2016

Sorry. My question is, why I cannot write just
Run ipdb (like this): ipdb /home/cactus/Dev/ownlibrary/play.py
Why I have to write the absolute path to ipdb?

@cpitclaudel
Copy link
Member

Does ipdb work in a terminal? If not, I'd guess ipdb is just not in your path.

@cactail
Copy link

cactail commented Jul 2, 2016

Yes, it works in a terminal. For some reason, GNU Emacs can't find ipdb and only find it with absolute path.

@cpitclaudel
Copy link
Member

@cactail You're not starting emacs from the terminal, are you? If so, then there's possibly a difference between the path that Emacs sees and the path that your terminal sees. Try echo $PATH in your shell and M-: (getenv "PATH") in Emacs.

@cactail
Copy link

cactail commented Jul 2, 2016

You're right! My ipdb script was in /home/cactus/.local/bin/
I move it to /usr/local/bin where Emacs can see it. (There's a difference between path, like you said) and now works fine with Run ipdb (like this): ipdb <path_to_python_file>.
Thank you for your answers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants