gef icon indicating copy to clipboard operation
gef copied to clipboard

Question about pyenv

Open samas69420 opened this issue 1 year ago • 5 comments

After my last pull request (#1058) I've noticed that the "is_dir()"assertion still fails when using "system" python version in pyenv and when virtual environments managed with pyenv-virtualenv are active, I did fix it but I'm not sure if I should open a new pull request since multiple site-packages directories from different python versions would be allowed to be simultaneously in sys.path and I don't know if this could lead to conflicts, maybe it would be better to just force users to set the global python version to "system" from pyenv and deactivate any virtual environment before running gdb if pyenv is detected

samas69420 avatar Jan 28 '24 21:01 samas69420

pyenv is the source of too many unwanted issue and I don't think it's gef's job to check if it's running in a venv or not. In addition, none of the pyenv checks are tested through our CI so it's a bit uncertain to know when bugs hit.

I don't know if this could lead to conflicts, maybe it would be better to just force users to set the global python version to "system" from pyenv and deactivate any virtual environment before running gdb if pyenv is detected

Exactly. As I mentioned in #1048 the correct approach IMO is simply to remove all code related to pyenv detection in gef itself, and instead we can have a standalone script (in scripts/ for instance) that will be here exactly for that purpose; script that must be loaded before gef in the gdbinit. We can easily do that and also provide documentation to assist on setting this up for users.

@samas69420 If you're willing to do this, such PR would be most welcome - simply because I don't think many of the other devs (include myself) use pyenv for gdb.

hugsy avatar Jan 29 '24 01:01 hugsy

what should the script do besides detecting pyenv?

samas69420 avatar Jan 29 '24 06:01 samas69420

what should the script do besides detecting pyenv?

Exactly that, but in a separate script:

https://github.com/hugsy/gef/blob/ece572826a4364de340a7b0ff18afa89f5e76119/gef.py#L11396-L11415

hugsy avatar Jan 29 '24 16:01 hugsy

And maybe leave an additional global variable or environment variable like RUNNING_IN_PYENV or something in case that's important to detect in the future (I doubt it, but it won't hurt).

hugsy avatar Jan 29 '24 16:01 hugsy

i can try, but anyway i already made a little edit on the code (still in gef.py tho), now users are forced to explicitly select "system" python version if they're using pyenv and if they don't do it they get a error message, i also moved the gef declaration above so i could use the err function to print the message, if it's ok i can open a PR https://github.com/samas69420/gef/blob/a1d1a62aa9826526fc985cf8d534beb563be9158/gef.py#L11383-L11444

samas69420 avatar Jan 30 '24 10:01 samas69420

pyenv support has been removed with #1084

Closing this issue

hugsy avatar May 19 '24 14:05 hugsy