Repository: thefuck
Issue: [Bug] Key error when running thefuck on termux
Labels: documentation

( 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 )

<!-- If you have any issue with The Fuck, sorry about that, but we will do what we
can to fix that. Actually, maybe we already have, so first thing to do is to
update The Fuck and see if the bug is still there. -->

<!-- If it is (sorry again), check if the problem has not already been reported and
if not, just open an issue on [GitHub](https://github.com/nvbn/thefuck) with
the following basic information: -->

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.

<!-- It's only with enough information that we can do something to fix the problem. -->