thefuck: [Bug] Key error when running thefuck on termux
( I will be crossposting it to termux’s issues as well because I don’t know if it’s a problem with termux https://github.com/termux/termux-app/issues/1646 )
The output of thefuck --version
(something like The Fuck 3.1 using Python 3.5.0 and Bash 4.4.12(1)-release
):
Can't run this, I get an error.
Your system (Debian 7, ArchLinux, Windows, etc.):
Debian (Termux on Android 10, Pixel 3)
How to reproduce the bug:
run: thefuck --version
or alternatively,
run: thefuck -h
The output of The Fuck with THEFUCK_DEBUG=true
exported (typically execute export THEFUCK_DEBUG=true
in your shell before The Fuck):
Traceback (most recent call last):
File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/psutil/_common.py", line 405, in wrapper return cache[key]
KeyError: (('/proc',), frozenset())
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/psutil/_pslinux.py", line 309, in <module>
set_scputimes_ntuple("/proc")
File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/psutil/_common.py", line 407, in wrapper ret = cache[key] = fun(*args, **kwargs)
File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/psutil/_pslinux.py", line 276, in set_scputimes_ntuple
with open_binary('%s/stat' % procfs_path) as f:
File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/psutil/_common.py", line 713, in open_binary
return open(fname, "rb", **kwargs) PermissionError: [Errno 13] Permission denied: '/proc/stat'
Traceback (most recent call last):
File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/psutil/_pslinux.py", line 1516, in wrapper
return fun(self, *args, **kwargs)
File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/psutil/_pslinux.py", line 1734, in create_time
bt = BOOT_TIME or boot_time()
File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/psutil/_pslinux.py", line 1435, in boot_time
with open_binary(path) as f:
File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/psutil/_common.py", line 713, in open_binary
return open(fname, "rb", **kwargs)
PermissionError: [Errno 13] Permission denied: '/proc/stat'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/data/data/com.termux/files/usr/bin/thefuck", line 5, in <module>
from thefuck.entrypoints.main import main
File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/thefuck/entrypoints/main.py", line 11, in <module>
from ..shells import shell # noqa: E402
File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/thefuck/shells/__init__.py", line 52, in <module>
shell = _get_shell_from_env() or _get_shell_from_proc()
File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/thefuck/shells/__init__.py", line 45, in _get_shell_from_proc
proc = proc.parent()
File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/psutil/__init__.py", line 561, in parent
ctime = self.create_time()
File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/psutil/__init__.py", line 723, in create_time
self._create_time = self._proc.create_time()
File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/psutil/_pslinux.py", line 1518, in wrapper
raise AccessDenied(self.pid, self._name)
psutil.AccessDenied: psutil.AccessDenied (pid=13945, name='thefuck')
If the bug only appears with a specific application, the output of that application and its version:
(N/A)
Anything else you think is relevant:
I'm using zsh as my shell, and my phone isn't rooted.
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 9
- Comments: 21
Same thing Here’s the answer from termux side: /proc is not readable on newer android versions, unless you are rooted. There is nothing we can do about this from termux side of things, hopefully thefuck can be patched to handle this keyerror better
Hope it’s going to be fixed for the sake of fucking on termux
Now I see. Thank you for the patience and great work!
Added a section to troubleshooting: https://github.com/nvbn/thefuck/wiki/Troubleshooting#usage-on-android-or-other-systems-that-forbid-access-to-proc
Thing is, The Fuck tries to guess your shell by inspecting its parent process and that information lives in
/proc
. So, if your user can’t access/proc
, you must specify the shell manually. This is what you need:The major issue would be the zombie processes. Check this out:
https://github.com/nvbn/thefuck/blob/841e3f9e13f52747c18319b55c77ece8095df306/thefuck/output_readers/rerun.py#L10-L43
Not only a long-running process (like vim or some other that requires user input) couldn’t be killed, it’s PID wouldn’t be displayed and the user would have to hunt them down somehow.
Wait. I guess there’s nothing wrong with The Fuck. What happens if you try the following?
Please post the complete error message for: