HorlogeSkynet / archey4

:computer: Maintained fork of the original Archey (Linux) system tool
https://git.io/archey4
GNU General Public License v3.0
291 stars 37 forks source link

[BUG] ERROR: archey.test.entries.test_archey_packages (unittest.loader._FailedTest) #101

Closed vasilejianu closed 3 years ago

vasilejianu commented 3 years ago

From https://aur.archlinux.org/packages/archey4/?O=10&PP=10#comment-825146.


getting this when trying to upgrade or clean install the latest build, any help ? thanks

==> Starting check()...
.......................................................E......................................................................................
======================================================================
ERROR: archey.test.entries.test_archey_packages
(unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module:
archey.test.entries.test_archey_packages
Traceback (most recent call last):
  File "/usr/lib/python3.9/unittest/loader.py", line 436, in
_find_test_path
    module = self._get_module_from_name(name)
  File "/usr/lib/python3.9/unittest/loader.py", line 377, in
_get_module_from_name
    __import__(name)
  File
"/home/vas/.cache/yay/archey4/src/archey4-4.13.1/archey/test/entries/test_archey_packages.py",
line 9, in <module>
    from archey.entries.packages import Packages
  File
"/home/vas/.cache/yay/archey4/src/archey4-4.13.1/archey/entries/packages.py",
line 34, in <module>
    {'cmd': ('ls', '-1', get_homebrew_cellar_path())},  # HomeBrew.
  File
"/home/vas/.cache/yay/archey4/src/archey4-4.13.1/archey/entries/packages.py",
line 14, in get_homebrew_cellar_path
    return check_output(
  File "/usr/lib/python3.9/subprocess.py", line 424, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/lib/python3.9/subprocess.py", line 505, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/lib/python3.9/subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.9/subprocess.py", line 1821, in
_execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: 'brew'

----------------------------------------------------------------------
Ran 142 tests in 1.304s

FAILED (errors=1)
==> ERROR: A failure occurred in check().
    Aborting...
error making: archey4

Hi @vasilejianu, thanks for your feedback. Have you got brew installed on your system ? Can you run brew --cellar manually ? I don't get why it would raise PermissionError exception, but we can catch it upstream in the future if needed... Bye, waiting for your input.


i don't have brew its weird is doing that its a minimal arch install Linux apex-main 5.13.13-arch1-1 #1 all i have is nginx,mariadb,php,named

which brew
which: no brew in
(/usr/local/sbin:/usr/local/bin:/usr/bin:/root/.dotnet/tools:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl)

@vasilejianu : so I've tried with yay myself against an Arch container, and the check() part is really doing well... I think something is to blamed on your system (noexec(?), yay configuration(?), somehow brew is available under PATH on your vas regular user(?), ...). If you find out, please let me know. If something is definitely wrong upstream, let me know too. Good luck


this is interesting i have run the test manually under user priv it fails , under root privs it passes

[vas@apex-main archey4]$ python3 -m unittest
.......................................................E......................................................................................
======================================================================
ERROR: archey.test.entries.test_archey_packages
(unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module:
archey.test.entries.test_archey_packages
Traceback (most recent call last):
  File "/usr/lib/python3.9/unittest/loader.py", line 436, in
_find_test_path
    module = self._get_module_from_name(name)
  File "/usr/lib/python3.9/unittest/loader.py", line 377, in
_get_module_from_name
    __import__(name)
  File
"/home/vas/archey4/archey/test/entries/test_archey_packages.py", line
9, in <module>
    from archey.entries.packages import Packages
  File "/home/vas/archey4/archey/entries/packages.py", line 34, in
<module>
    {'cmd': ('ls', '-1', get_homebrew_cellar_path())},  # HomeBrew.
  File "/home/vas/archey4/archey/entries/packages.py", line 14, in
get_homebrew_cellar_path
    return check_output(
  File "/usr/lib/python3.9/subprocess.py", line 424, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/lib/python3.9/subprocess.py", line 505, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/lib/python3.9/subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.9/subprocess.py", line 1821, in
_execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: 'brew'

----------------------------------------------------------------------
Ran 142 tests in 1.315s

FAILED (errors=1)
[vas@apex-main archey4]$ sudo python3 -m unittest
...........................................................................................................................................................
----------------------------------------------------------------------
Ran 155 tests in 1.302s

OK

@vasilejianu : could you try to run which brew under your regular user ? You can also use a (broad) find if nothing comes out; I'm pretty sure you got a brew (apparently not executable) somewhere. Almost there !


find . -name "brew*"
./root/.oh-my-bash/completions/brew.completion.sh
./root/.oh-my-bash/plugins/brew
./root/.oh-my-bash/plugins/brew/brew.plugin.sh

@vasilejianu : good one. Although I'm confused about catching PermissionError in this case, as all the other sub-process calls across the code base do not, whereas the same problem could occur. What do you think about that ? Do you think this exception should be caught elsewhere ?


idk although that was the only ref to brew in the system i have uninstalled oh my bash and still getting the error i have tried under a diff user too

root@apex-main>  find . -name "brew*"
root@apex-main> which brew
brew not found

apex-main% printenv
USER=vas
LOGNAME=vas
HOME=/home/vas
PATH=/root/.local/bin:/other/things/in/path:/usr/local/sbin:/usr/local/bin:/usr/bin:/root/.dotnet/tools:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
SHELL=/bin/zsh
TERM=xterm-256color
MOTD_SHOWN=pam
MAIL=/var/spool/mail/root
XDG_SESSION_ID=12
XDG_RUNTIME_DIR=/run/user/0
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/0/bus
XDG_SESSION_TYPE=tty
XDG_SESSION_CLASS=user
SSH_CLIENT=...
SSH_CONNECTION=...
SSH_TTY=/dev/pts/0
SHLVL=2
PWD=/
OLDPWD=/
DOTNET_ROOT=/usr/share/dotnet
DOTNET_BUNDLE_EXTRACT_BASE_DIR=/root/.cache/dotnet_bundle_extract
LANG=en_US.UTF-8
_=/usr/bin/printenv

@vasilejianu : have you tried under another BASH session without brew symbol exported by your previous plugin ? [...]


yeah i have installed zsh, was previously using bash i have removed the user and added it again with a new zsh shell

HorlogeSkynet commented 3 years ago

Thanks for opening this up !

I'm preparing a patch to properly catch PermissionError for sub-process calls that might raise it. For your case, I'd rather prefer we debug it completely beforehand though. Could you run strace brew under your regular user so we definitely understand what is going on here ?

Thanks for your time :bow:

vasilejianu commented 3 years ago

vas@apex-main> strace brew ~ strace: Can't stat 'brew': No such file or directory

as i said i never had brew installed only mention was in the oh my bash files had had some reference to a plugin but that plugin wasn't installed either

HorlogeSkynet commented 3 years ago

So I can't see why you keep getting PermissionError then. I've noticed you are connected through SSH, have you tried under another session ? I really fear there is a remaining symbol exported in your environment by the (now uninstalled) BASH plugin.

vasilejianu commented 3 years ago

that fixed it , i ran a connection to the user instead of root and using su user and it worked Thanks :)

HorlogeSkynet commented 3 years ago

Perfect, I think we properly narrowed this down, I'll publish the patch I was talking about and make it point to this issue. No problem, thanks to you :bow: