[2.18][PATCH] bitbake-worker: Evaluate exported_vars() before emptying the environment
exported_vars() returns a lazy generator. It was bound before empty_environment() cleared the process environment and only iterated afterwards, so any datastore expansion deferred until iteration ran with PATH already wiped.
Recipes whose exported variables expand a command during that loop hit this. A gitver-style PV such as "${@get_git_pv(d, ...)}" runs git while PATH is empty, so the git wrapper on PATH is bypassed and the real git runs directly. Under pseudo this fakes uid 0 against a repository owned by the real user, and git aborts with "detected dubious ownership", failing do_package intermittently (only on reparse, when the value is re-expanded rather than served from cache).
Materialise the generator into a list before emptying the environment so every expansion happens while PATH is still intact.
--- bin/bitbake-worker | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
bin/bitbake-worker +1 -1
@@ -290,7 +290,7 @@ def fork_off_task(cfg, data, databuilder, workerdata, extraconfigdata, runtask): # exported_vars() returns a generator which *cannot* be passed to os.environ.update() # successfully. We also need to unset anything from the environment which shouldn't be there - exports = bb.data.exported_vars(the_data) + exports = list(bb.data.exported_vars(the_data)) bb.utils.empty_environment() for e, v in exports:
Signature · 1 line
2.47.3
Quoted 28 lines · Alejandro Mery via lists.openembedded.org
exported_vars()returns a lazy generator. It was bound beforeempty_environment()cleared the process environment and only iterated afterwards, so any datastore expansion deferred until iteration ran with PATH already wiped.Recipes whose exported variables expand a command during that loop hit this. A gitver-style PV such as "${@get_git_pv(d, ...)}" runs git while PATH is empty, so the git wrapper on PATH is bypassed and the real git runs directly. Under pseudo this fakes uid 0 against a repository owned by the real user, and git aborts with "detected dubious ownership", failing
do_packageintermittently (only on reparse, when the value is re-expanded rather than served from cache).Materialise the generator into a list before emptying the environment so every expansion happens while PATH is still intact.
Signed-off-by Alejandro Mery <[email protected]>---
bin/bitbake-worker | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)bin/bitbake-worker +0
-0@@ -290,7 +290,7 @@ def fork_off_task(cfg, data, databuilder, workerdata, extraconfigdata, runtask):
#exported_vars()returns a generator which *cannot* be passed toos.environ.update()
Quoted 6 lines
# successfully. We also need to unset anything from the environment which shouldn't be there - exports = bb.data.exported_vars(the_data) + exports = list(bb.data.exported_vars(the_data)) bb.utils.empty_environment() for e, v in exports:
Thanks for this. Nice work in tracking it down!
I think in this case we need a couple of things, firstly will be a bit more explination in the code with a comment about why we need a list there.
The failure case is so unusual we should also probably write a test case to make sure we test for and don't regress that issue which we'd add to the existing tests in bitbake-selftest.
Help with that would be welcome or we'll get to it when we can...
Cheers,
Richard
Quoted 41 lines · Richard Purdie
Quoted 26 lines · Alejandro Mery via lists.openembedded.org
exported_vars()returns a lazy generator. It was bound beforeempty_environment()cleared the process environment and only iterated afterwards, so any datastore expansion deferred until iteration ran with PATH already wiped.Recipes whose exported variables expand a command during that loop hit this. A gitver-style PV such as "${@get_git_pv(d, ...)}" runs git while PATH is empty, so the git wrapper on PATH is bypassed and the real git runs directly. Under pseudo this fakes uid 0 against a repository owned by the real user, and git aborts with "detected dubious ownership", failing
do_packageintermittently (only on reparse, when the value is re-expanded rather than served from cache).Materialise the generator into a list before emptying the environment so every expansion happens while PATH is still intact.
Signed-off-by Alejandro Mery <[email protected]>--- bin/bitbake-worker | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)bin/bitbake-worker +0
-0bin/bitbake-worker def fork_off_task(cfg, data, databuilder, workerdata, extraconfigdata, runtask): · line 296
Quoted 8 lines
bin/bitbake-worker +1
-1@@ -290,7 +290,7 @@ def fork_off_task(cfg, data, databuilder, workerdata, extraconfigdata, runtask): # exported_vars() returns a generator which *cannot* be passed to os.environ.update() # successfully. We also need to unset anything from the environment which shouldn't be there - exports = bb.data.exported_vars(the_data) + exports = list(bb.data.exported_vars(the_data)) bb.utils.empty_environment() for e, v in exports:Thanks for this. Nice work in tracking it down!
I think in this case we need a couple of things, firstly will be a bit more explination in the code with a comment about why we need a list there.
Quoted 5 lines
The failure case is so unusual we should also probably write a test case to make sure we test for and don't regress that issue which we'd add to the existing tests in bitbake-selftest.
Help with that would be welcome or we'll get to it when we can...
I'll send a v2 soon
Quoted 47 lines · Alejandro Mery via lists.openembedded.org
Quoted 1 line · Richard Purdie
On Mon, 2026-07-20 at 19:58 +0000, Alejandro Mery via
Quoted 21 lines · lists.openembedded.org
Quoted 21 lines
exported_vars()returns a lazy generator. It was bound beforeempty_environment()cleared the process environment and only iterated afterwards, so any datastore expansion deferred until iteration ran with PATH already wiped.Recipes whose exported variables expand a command during that loop hit this. A gitver-style PV such as "${@get_git_pv(d, ...)}" runs git while PATH is empty, so the git wrapper on PATH is bypassed and the real git runs directly. Under pseudo this fakes uid 0 against a repository owned by the real user, and git aborts with "detected dubious ownership", failing
do_packageintermittently (only on reparse, when the value is re-expanded rather than served from cache).Materialise the generator into a list before emptying the environment so every expansion happens while PATH is still intact.
Signed-off-by Alejandro Mery <[email protected]>--- bin/bitbake-worker | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Quoted 5 lines
bin/bitbake-worker def fork_off_task(cfg, data, databuilder,
Quoted 5 lines
bin/bitbake-worker +0
-0@@ -290,7 +290,7 @@ def fork_off_task(cfg, data, databuilder,workerdata, extraconfigdata, runtask):
Quoted 2 lines
bin/bitbake-worker def fork_off_task(cfg, data, databuilder, · line 290
Quoted 2 lines
bin/bitbake-worker +0
-0# exported_vars() returns a generator which *cannot*be passed to
os.environ.update()Quoted 1 line
bin/bitbake-worker def fork_off_task(cfg, data, databuilder, · line 291
Quoted 1 line
bin/bitbake-worker +0
-0# successfully. We also need to unset anything fromthe environment which shouldn't be there
Quoted 11 lines
bin/bitbake-worker def fork_off_task(cfg, data, databuilder, workerdata, extraconfigdata, runtask): · line 296
Quoted 5 lines
bin/bitbake-worker +1
-1- exports = bb.data.exported_vars(the_data) + exports = list(bb.data.exported_vars(the_data)) bb.utils.empty_environment() for e, v in exports:Thanks for this. Nice work in tracking it down!
I think in this case we need a couple of things, firstly will be a bit more explination in the code with a comment about why we need a list there.
Quoted 9 lines
Quoted 5 lines
The failure case is so unusual we should also probably write a test case to make sure we test for and don't regress that issue which we'd add to the existing tests in bitbake-selftest.
Help with that would be welcome or we'll get to it when we can...
I'll send a v2 soon
Is this for master? In that case, please remove the [2.18] tag.
Thanks!
Signature · 1 line
Yoann Congal