Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 923439 - 'eclean packages' fails with InvalidDependString
Summary: 'eclean packages' fails with InvalidDependString
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Binary packages support (show other bugs)
Hardware: AMD64 Linux
: Normal major
Assignee: Portage Tools Team
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks:
 
Reported: 2024-02-01 01:51 UTC by Stuart Shelton
Modified: 2024-05-03 12:10 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stuart Shelton 2024-02-01 01:51:26 UTC
With dev-lang/python-3.11.7, sys-apps/portage-3.0.61-r1, app-portage/gentoolkit-0.6.3-r1:

```
$ sudo emaint binhost -f
Emaint: fix binhost        100% [============================================>]
$ sudo eclean -p packages --changed-deps --unique-use
 * Building file list for packages cleaning...
Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.11/eclean", line 41, in <module>
    main()
  File "/usr/lib/python3.11/site-packages/gentoolkit/eclean/cli.py", line 721, in main
    doAction(action, options, exclude=exclude, output=output)
  File "/usr/lib/python3.11/site-packages/gentoolkit/eclean/cli.py", line 553, in doAction
    clean_me, invalids = findPackages(
                         ^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/gentoolkit/eclean/search.py", line 625, in findPackages
    if _deps_equal(
       ^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/gentoolkit/eclean/search.py", line 505, in _deps_equal
    deps_b = use_reduce(deps_b, uselist=uselist, eapi=eapi_b, token_class=Atom)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/portage/dep/__init__.py", line 942, in use_reduce
    result = _use_reduce_cached(
             ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/portage/dep/__init__.py", line 633, in _use_reduce_cached
    raise InvalidDependString(
portage.exception.InvalidDependString: expected: dependency string, got: ')', token 65
```

This happens on two separate binhosts, but both report 'token 65'.

${PKGDIR}/Packages is 62,388 lines long in one affected instance and 64,431 in another.

'eclean' needs to output the line or affected package when this type of error occurs, as from the information above I can see no indicated way to fix the problem.


Reproducible: Always

Steps to Reproduce:
1. Run 'emaint binhost -f' to try to make the binhost consistent;
2. Run 'eclean -p packages --changed-deps --unique-use'
Actual Results:  
portage.exception.InvalidDependString raised

Expected Results:  
'eclean' should complete and output a package list to be pruned, issuing only a non-fatal warning for the affected package(s).

eclean should report exactly where the error occurred (by line-number or package name) so that it can be fixed manually, or 'emaint binhost' should resolve this problem when run automagically.

I have this error on an AMD64 and an ARM64 binhost.

N.B. This only occurs if `--changed-deps` is used as an argument to 'eclean'.
Comment 1 Brian Dolbec (RETIRED) gentoo-dev 2024-02-04 22:05:44 UTC
I've added some code to output the info I think will help you solve the issue at my github account.  It was from before gentoolkit was on gentoo's github so can't make the pr yet.

Please try it out. I was unable to reproduce on my system

https://github.com/dol-sen/gentoolkit/tree/master

edit the following to your checkout path to run the checkout code directly

export PATH="/home/brian/Dev/git/gentoolkit/bin:${PATH}"

export PYTHONPATH="/home/brian/Dev/git/gentoolkit/pym/:${PYTHONPATH}"
Comment 2 Brian Dolbec (RETIRED) gentoo-dev 2024-02-05 02:48:57 UTC
OK, created the fork, please see the PR at:

https://github.com/gentoo/gentoolkit/pull/43
Comment 3 Brian Dolbec (RETIRED) gentoo-dev 2024-02-05 02:56:35 UTC
Please test this and report back any details you find BEFORE you fix them.  Make a copy, upload it here in case there is an underlying cause in portage code that created it.  There have been numerous changes to the binpkg code.
Comment 4 Stuart Shelton 2024-02-05 19:18:53 UTC
Hmm - the output has changed, but it looks as if it's still not telling me where the problem lies?

```
 sudo eclean -p packages --changed-deps --unique-use
 * Building file list for packages cleaning...
Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/gentoolkit/eclean/search.py", line 663, in findPackages
    if _deps_equal(
       ^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/gentoolkit/eclean/search.py", line 536, in _deps_equal
    deps_b = use_reduce(deps_b, uselist=uselist, eapi=eapi_b, token_class=Atom)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/portage/dep/__init__.py", line 942, in use_reduce
    result = _use_reduce_cached(
             ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/portage/dep/__init__.py", line 633, in _use_reduce_cached
    raise InvalidDependString(
portage.exception.InvalidDependString: expected: dependency string, got: ')', token 65

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.11/eclean", line 41, in <module>
    main()
  File "/usr/lib/python3.11/site-packages/gentoolkit/eclean/cli.py", line 737, in main
    doAction(action, options, exclude=exclude, output=output)
  File "/usr/lib/python3.11/site-packages/gentoolkit/eclean/cli.py", line 565, in doAction
    clean_me, invalids = findPackages(
                         ^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/gentoolkit/eclean/search.py", line 674, in findPackages
    pp.error("findPackages", "InvalidDependString found for: %s" % cpv),
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: error() takes 1 positional argument but 2 were given
```
Comment 5 Stuart Shelton 2024-02-05 19:24:02 UTC
(I've reported this on the PR too - looks as if the invocation of `pp.error()` isn't quite right?)
Comment 6 Brian Dolbec (RETIRED) gentoo-dev 2024-02-05 20:28:58 UTC
fixed the error, force pushed the PR.

I also am working on a final version which handles bad binpkgs with a warning and continue to delete it.

I'll wait to push that till after I've been able to properly test it.
Comment 7 Stuart Shelton 2024-02-06 09:48:09 UTC
(Mirroring response to PR for visibility)

Ah - now this is useful (although is the "another exception" exception expected?)

```
$ sudo eclean -p packages --changed-deps
 * Building file list for packages cleaning...
!!! findPackages: InvalidDependString found for: app-editors/vim-8.2.4586

!!! findPackages: deps_binpkg: >=app-eselect/eselect-vi-1.1 >=sys-libs/ncurses-5.2-r2:0/6= ~app-editors/vim-core-8.2.4586 !<app-editors/vim-core-8.2.4328-r1 

!!! findPackages: deps_ebuild: >=app-eselect/eselect-vi-1.1 >=sys-libs/ncurses-5.2-r2:0= nls? ( virtual/libintl ) acl? ( kernel_linux? ( sys-apps/acl ) ) crypt? ( dev-libs/libsodium:= ) cscope? ( dev-util/cscope ) gpm? ( >=sys-libs/gpm-1.19.3 ) lua? ( lua_single_target_luajit? ( dev-lang/luajit:= ) lua_single_target_lua5-1? ( dev-lang/lua:5.1 ) lua_single_target_lua5-1? ( dev-lang/lua:5.1[deprecated] ) ) ~app-editors/vim-core-8.2.4586 !<app-editors/vim-core-8.2.4328-r1 vim-pager? ( app-editors/vim-core[-minimal] ) perl? ( dev-lang/perl:= ) python? ( python_single_target_python3_10? ( dev-lang/python:3.10[threads(+)] ) ) racket? ( dev-scheme/racket ) ruby? ( || ( ) ) selinux? ( sys-libs/libselinux ) sound? ( media-libs/libcanberra ) tcl? ( dev-lang/tcl:0= ) X? ( x11-libs/libXt ) 

Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/gentoolkit/eclean/search.py", line 663, in findPackages
    if _deps_equal(
       ^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/gentoolkit/eclean/search.py", line 536, in _deps_equal
    deps_b = use_reduce(deps_b, uselist=uselist, eapi=eapi_b, token_class=Atom)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/portage/dep/__init__.py", line 942, in use_reduce
    result = _use_reduce_cached(
             ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/portage/dep/__init__.py", line 633, in _use_reduce_cached
    raise InvalidDependString(
portage.exception.InvalidDependString: expected: dependency string, got: ')', token 65

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.11/eclean", line 41, in <module>
    main()
  File "/usr/lib/python3.11/site-packages/gentoolkit/eclean/cli.py", line 737, in main
    doAction(action, options, exclude=exclude, output=output)
  File "/usr/lib/python3.11/site-packages/gentoolkit/eclean/cli.py", line 565, in doAction
    clean_me, invalids = findPackages(
                         ^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/gentoolkit/eclean/search.py", line 685, in findPackages
    print(pp.error(er))
          ^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/gentoolkit/pprinter.py", line 69, in error
    return output.red("!!! ") + string + "\n"
           ~~~~~~~~~~~~~~~~~~~^~~~~~~~
TypeError: can only concatenate str (not "InvalidDependString") to str
```

… is looks as if the issue is an empty Ruby dependency - so I guess my follow-on questions are:

1. Should an empty dependency such as this be a full-blown error, or just a warning, or be silently accepted?

2. Can this legitimately happen on platforms (such as this one, ARM64) which aren't as broadly keyworded as others, where there genuinely is no unmasked ruby package at any time?
Comment 8 Brian Dolbec (RETIRED) gentoo-dev 2024-02-06 15:16:40 UTC
yeah, that is a good question.

@zmedico: use_reduce is puking on "ruby? ( || ( ) )" from the ebuild deps

Portage/emerge must be handling this differently to not have had this issue otherwise.  How do we handle tjhis?
Comment 9 Larry the Git Cow gentoo-dev 2024-02-18 02:19:40 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=70cb55fa5fd2af7c7e46c94dc423a96bbedd83a5

commit 70cb55fa5fd2af7c7e46c94dc423a96bbedd83a5
Author:     Brian Dolbec <dolsen@gentoo.org>
AuthorDate: 2024-02-04 21:00:49 +0000
Commit:     Brian Dolbec <dolsen@gentoo.org>
CommitDate: 2024-02-18 02:16:03 +0000

    eclean: Handle InvalidDepstring info in _deps_equal
    
    Add try/except pair to _deps_equal() to output relavent details
    causing the exception in order to aid the user to fix the issue.
    Mark binpkg dep failures as a non match for possible deletion.
    Make the ebuild dep failure a warning only, return True to save
    the binpkg.
    Add parameter docstring info
    
    Bug: https://bugs.gentoo.org/923439
    Signed-off-by: Brian Dolbec <dolsen@gentoo.org>

 pym/gentoolkit/eclean/search.py | 54 ++++++++++++++++++++++++++++++++++++-----
 1 file changed, 48 insertions(+), 6 deletions(-)
Comment 10 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-04-25 23:43:30 UTC
Fixed in 0.6.6.