Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 687814 - sys-apps/portage-2.3.67 - UnboundLocalError: local variable 'packages_list' referenced before assignment
Summary: sys-apps/portage-2.3.67 - UnboundLocalError: local variable 'packages_list' r...
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Unclassified (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks: 686768
  Show dependency tree
 
Reported: 2019-06-10 17:44 UTC by Francesco Turco
Modified: 2019-08-01 19:19 UTC (History)
0 users

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 Francesco Turco 2019-06-10 17:44:32 UTC
When I run "emerge --info" I get the following error message:

# emerge --info
Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.7/emerge", line 53, in <module>
    retval = emerge_main()
  File "/usr/lib/python3.7/site-packages/_emerge/main.py", line 1265, in emerge_main
    action=myaction, args=myfiles, opts=myopts)
  File "/usr/lib/python3.7/site-packages/portage/proxy/objectproxy.py", line 31, in __call__
    return result(*args, **kwargs)
  File "/usr/lib/python3.7/site-packages/_emerge/actions.py", line 2461, in load_emerge_config
    **kwargs)
  File "/usr/lib/python3.7/site-packages/portage/__init__.py", line 550, in create_trees
    env=env, sysroot=sysroot, eprefix=eprefix)
  File "/usr/lib/python3.7/site-packages/portage/package/ebuild/config.py", line 604, in __init__
    self.packages = tuple(stack_lists(packages_list, incremental=1))
UnboundLocalError: local variable 'packages_list' referenced before assignment

This problem started happening approximately at the same time when I started adding some /etc/portage configuration files to my system dotfiles, using symlinks. For example /etc/portage/make.conf is now a symlink to /etc/dotfiles/portage/make.conf. /etc/dotfiles is my git repository for system dotfiles. But I'm not sure if this is the cause of the error message.

I get similar error messages with other commands such as "emaint sync -a", "emerge --depclean" and "emerge --search gcc".

For obvious reasons I cannot attach my "emerge --info" log to this bug report.

Reproducible: Always
Comment 1 Zac Medico gentoo-dev 2019-06-10 18:11:40 UTC
Some kind of IOError triggers this, and the bug comes from this commit:

https://gitweb.gentoo.org/proj/portage.git/commit/?id=55b2e1c0a51d64a84e5649c135cdbc2c650ce6ca

Hopefully it will give a more meaningful error if you patch /usr/lib/python3.7/site-packages/portage/package/ebuild/config.py with a raise statement like this:

> diff --git a/lib/portage/package/ebuild/config.py b/lib/portage/package/ebuild/config.py
> index cc2413989..858dd324f 100644
> --- a/lib/portage/package/ebuild/config.py
> +++ b/lib/portage/package/ebuild/config.py
> @@ -600,6 +600,7 @@ class config(object):
>  				if e.errno == IsADirectory.errno:
>  					raise IsADirectory(os.path.join(self.profile_path,
>  									 "packages"))
> +				raise
>  
>  			self.packages = tuple(stack_lists(packages_list, incremental=1))
>
Comment 2 Larry the Git Cow gentoo-dev 2019-06-10 19:01:03 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/portage.git/commit/?id=c8e59b89b3d8f1fea20ec787c65d83becc0070ff

commit c8e59b89b3d8f1fea20ec787c65d83becc0070ff
Author:     Zac Medico <zmedico@gentoo.org>
AuthorDate: 2019-06-10 18:28:56 +0000
Commit:     Zac Medico <zmedico@gentoo.org>
CommitDate: 2019-06-10 18:47:39 +0000

    config: don't swallow IOError for "packages" files (bug 687814)
    
    Fixes: 55b2e1c0a51d ("Turn a traceback into a graceful error")
    Bug: https://bugs.gentoo.org/687814
    Signed-off-by: Zac Medico <zmedico@gentoo.org>

 lib/portage/package/ebuild/config.py | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
Comment 3 Francesco Turco 2019-06-10 19:33:47 UTC
I edited /usr/lib/python3.7/site-packages/portage/package/ebuild/config.py as you said. Now I get the following error message:

# emerge --info
Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.7/emerge", line 53, in <module>
    retval = emerge_main()
  File "/usr/lib/python3.7/site-packages/_emerge/main.py", line 1265, in emerge_main
    action=myaction, args=myfiles, opts=myopts)
  File "/usr/lib/python3.7/site-packages/portage/proxy/objectproxy.py", line 31, in __call__
    return result(*args, **kwargs)
  File "/usr/lib/python3.7/site-packages/_emerge/actions.py", line 2461, in load_emerge_config
    **kwargs)
  File "/usr/lib/python3.7/site-packages/portage/__init__.py", line 550, in create_trees
    env=env, sysroot=sysroot, eprefix=eprefix)
  File "/usr/lib/python3.7/site-packages/portage/package/ebuild/config.py", line 598, in __init__
    for x in profiles_complex]
  File "/usr/lib/python3.7/site-packages/portage/package/ebuild/config.py", line 598, in <listcomp>
    for x in profiles_complex]
  File "/usr/lib/python3.7/site-packages/portage/util/__init__.py", line 478, in grabfile_package
    pkgs=grabfile(myfilename, compatlevel, recursive=recursive, remember_source_file=True)
  File "/usr/lib/python3.7/site-packages/portage/util/__init__.py", line 131, in grabfile
    mylines = grablines(myfilename, recursive, remember_source_file=True)
  File "/usr/lib/python3.7/site-packages/portage/util/__init__.py", line 574, in grablines
    mode='r', encoding=_encodings['content'], errors='replace') as myfile:
NotADirectoryError: [Errno 20] Not a directory: b'/etc/portage/profile/packages'

On my system /etc/portage/profile is a symlink to /etc/dotfiles/portage/profile. The latter is a regular file, not a directory. With the following content:

-*sys-apps/openrc
-*sys-apps/busybox
-*sys-apps/net-tools

I fixed the problem by making /etc/portage/profile a directory and moving the previous three lines to /etc/portage/profile/packages:

# ls -l /etc/portage/profile/packages
lrwxrwxrwx 1 root root 38 Jun 10 21:31 /etc/portage/profile/packages -> /etc/dotfiles/portage/profile/packages

Now I can run "emerge --info" without any problems!