osrf / rocker

A tool to run docker containers with overlays and convenient options for things like GUIs etc.
Apache License 2.0
555 stars 70 forks source link

user extension broken: argument of type 'bool' is not iterable #223

Closed qw8z5fUB closed 1 year ago

qw8z5fUB commented 1 year ago

Reproducible example:

python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install git+https://github.com/osrf/rocker.git@d5e9ecf # current commit at time of writing
rocker --user ros:humble

Gives error:

Traceback (most recent call last):
  File "/tmp/rocker_fix/venv/bin/rocker", line 8, in <module>
    sys.exit(main())
  File "/tmp/rocker_fix/venv/lib/python3.8/site-packages/rocker/cli.py", line 64, in main
    dig = DockerImageGenerator(active_extensions, args_dict, base_image)
  File "/tmp/rocker_fix/venv/lib/python3.8/site-packages/rocker/core.py", line 209, in __init__
    self.dockerfile = generate_dockerfile(active_extensions, self.cliargs, base_image)
  File "/tmp/rocker_fix/venv/lib/python3.8/site-packages/rocker/core.py", line 348, in generate_dockerfile
    dockerfile_str += el.get_snippet(args_dict) + '\n'
  File "/tmp/rocker_fix/venv/lib/python3.8/site-packages/rocker/extensions.py", line 279, in get_snippet
    matched_groups = [g for g in all_groups if g.gr_name in cliargs['user_preserve_groups']]
  File "/tmp/rocker_fix/venv/lib/python3.8/site-packages/rocker/extensions.py", line 279, in <listcomp>
    matched_groups = [g for g in all_groups if g.gr_name in cliargs['user_preserve_groups']]
TypeError: argument of type 'bool' is not iterable

System info:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.5 LTS
Release:    20.04
Codename:   focal

$ python --version
Python 3.8.10

I put a debug print before line 279 in extensions.py: print(f"{cliargs['user_preserve_groups']=}") Which gives output: cliargs['user_preserve_groups']=False That appears to be the boolean value referred to in the type error 'argument of type 'bool' is not iterable'.

I believe this was introduced by 514aa6fe4f58fd75cf96669f1400936787aa7dd2, which went in 10 hours ago.

It looks like this is an issue in the current release versioned version on pypi (0.2.11), and I assume the same is true for other release channels. It would be nice if another release is made after this fix, so that the --user flag works on the released version.

tfoote commented 1 year ago

0.2.12 is being uploaded now

qw8z5fUB commented 1 year ago

Thanks for the quick fix. I'm a big fan of rocker!