yocto.lists.yoctoproject.org archive mirror
 help / color / mirror / Atom feed
* Environmental variable present in do_compile() {}, bitbake recipe -e, but is missing from do_configure() {} #bitbake
@ 2025-07-16 21:20 joseph.maniaci
  2025-07-17  9:46 ` [yocto] " Alexander Kanavin
  0 siblings, 1 reply; 13+ messages in thread
From: joseph.maniaci @ 2025-07-16 21:20 UTC (permalink / raw)
  To: yocto

[-- Attachment #1: Type: text/plain, Size: 362 bytes --]

So to be clear, when I execute bitbake my-recipe -e | grep "MY_VAR'", it is present.

If I make it as far as the do_compile() step, I can also capture the 'export' command and see that it is present.

However, at the do_configure() step, it, as well as a bunch of other stuff is missing.

Is this intentional? A bug? Documented somewhere?

Thanks,
Joe

[-- Attachment #2: Type: text/html, Size: 489 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [yocto] Environmental variable present in do_compile() {}, bitbake recipe -e, but is missing from do_configure() {} #bitbake
  2025-07-16 21:20 Environmental variable present in do_compile() {}, bitbake recipe -e, but is missing from do_configure() {} #bitbake joseph.maniaci
@ 2025-07-17  9:46 ` Alexander Kanavin
  2025-07-17 16:24   ` joseph.maniaci
  2025-07-17 16:27   ` joseph.maniaci
  0 siblings, 2 replies; 13+ messages in thread
From: Alexander Kanavin @ 2025-07-17  9:46 UTC (permalink / raw)
  To: yocto, joseph.maniaci

You are not showing anything useful about your configuration and
environment and recipe that needs the variable. What is the variable?
Where is it being set? Where is it being exported? How did you
determine that it is present in one task but absent in another? What
is the 'bunch of other stuff'?

The answer to your question is that it is almost certainly a
mis-configuration in your local build.

Alex

On Wed, 16 Jul 2025 at 23:20, joseph.maniaci via
lists.yoctoproject.org
<joseph.maniaci=seagate.com@lists.yoctoproject.org> wrote:
>
> So to be clear, when I execute bitbake my-recipe -e | grep "MY_VAR'", it is present.
>
> If I make it as far as the do_compile() step, I can also capture the 'export' command and see that it is present.
>
> However, at the do_configure() step, it, as well as a bunch of other stuff is missing.
>
> Is this intentional? A bug? Documented somewhere?
>
> Thanks,
> Joe
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#65669): https://lists.yoctoproject.org/g/yocto/message/65669
> Mute This Topic: https://lists.yoctoproject.org/mt/114193163/1686489
> Mute #bitbake:https://lists.yoctoproject.org/g/yocto/mutehashtag/bitbake
> Group Owner: yocto+owner@lists.yoctoproject.org
> Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [alex.kanavin@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [yocto] Environmental variable present in do_compile() {}, bitbake recipe -e, but is missing from do_configure() {} #bitbake
  2025-07-17  9:46 ` [yocto] " Alexander Kanavin
@ 2025-07-17 16:24   ` joseph.maniaci
  2025-07-17 16:29     ` Quentin Schulz
  2025-07-17 16:27   ` joseph.maniaci
  1 sibling, 1 reply; 13+ messages in thread
From: joseph.maniaci @ 2025-07-17 16:24 UTC (permalink / raw)
  To: Alexander Kanavin, yocto

[-- Attachment #1: Type: text/plain, Size: 273 bytes --]

So in experimenting, I learned that if I did a 'export ABC=3' in my environment followed by a 'bitbake whatever', the ABC environment variable would persist all the way to the do_compile(). However, what I found weird is that it is not present in the do_configure() step.

[-- Attachment #2: Type: text/html, Size: 303 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [yocto] Environmental variable present in do_compile() {}, bitbake recipe -e, but is missing from do_configure() {} #bitbake
  2025-07-17  9:46 ` [yocto] " Alexander Kanavin
  2025-07-17 16:24   ` joseph.maniaci
@ 2025-07-17 16:27   ` joseph.maniaci
  1 sibling, 0 replies; 13+ messages in thread
From: joseph.maniaci @ 2025-07-17 16:27 UTC (permalink / raw)
  To: Alexander Kanavin, yocto

[-- Attachment #1: Type: text/plain, Size: 577 bytes --]

So in experimenting, I learned that if I did a 'export ABC=3' in my environment followed by a 'bitbake whatever', the ABC environment variable would persist all the way to the do_compile(). However, what I found weird is that it is not present in the do_configure() step.

To confirm it was present, period, I can see it in 'bitbake whatever -e'. I can, in the do_compile() step, execute 'export > do_compile.out', examine the file and see 'export ABC=3'. I can, in the do_configure() step, execute 'export > do_configure.out', examine the file and see that it isn't there.

[-- Attachment #2: Type: text/html, Size: 622 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [yocto] Environmental variable present in do_compile() {}, bitbake recipe -e, but is missing from do_configure() {} #bitbake
  2025-07-17 16:24   ` joseph.maniaci
@ 2025-07-17 16:29     ` Quentin Schulz
  2025-07-17 16:48       ` joseph.maniaci
  0 siblings, 1 reply; 13+ messages in thread
From: Quentin Schulz @ 2025-07-17 16:29 UTC (permalink / raw)
  To: yocto, joseph.maniaci, Alexander Kanavin

Hi Joseph,

On 7/17/25 6:24 PM, joseph.maniaci via lists.yoctoproject.org wrote:
> So in experimenting, I learned that if I did a 'export ABC=3' in my environment followed by a 'bitbake whatever', the ABC environment variable would persist all the way to the do_compile(). However, what I found weird is that it is not present in the do_configure() step.
> 

You need to allow environment variables to be passed through to bitbake. 
This is done via BB_ENV_PASSTHROUGH/BB_ENV_PASSTHROUGH_ADDITIONS 
variable in your local.conf for example.

So you would have something like

BB_ENV_PASSTHROUGH_ADDITIONS="ABC"

I believe.

I'm surprised though that the variable is found by bitbake at all.

Cheers,
Quentin


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [yocto] Environmental variable present in do_compile() {}, bitbake recipe -e, but is missing from do_configure() {} #bitbake
  2025-07-17 16:29     ` Quentin Schulz
@ 2025-07-17 16:48       ` joseph.maniaci
  2025-07-17 17:20         ` Gyorgy Sarvari
  0 siblings, 1 reply; 13+ messages in thread
From: joseph.maniaci @ 2025-07-17 16:48 UTC (permalink / raw)
  To: Quentin Schulz, yocto

[-- Attachment #1: Type: text/plain, Size: 178 bytes --]

Ah, I'm using a script to do this in a repeatable fashion, so I forgot that the last thing it does is

export BB_ENV_PASSTHROUGH_ADDITIONS="$BB_ENV_PASSTHROUGH_ADDITIONS ABC"

[-- Attachment #2: Type: text/html, Size: 231 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [yocto] Environmental variable present in do_compile() {}, bitbake recipe -e, but is missing from do_configure() {} #bitbake
  2025-07-17 16:48       ` joseph.maniaci
@ 2025-07-17 17:20         ` Gyorgy Sarvari
  2025-07-17 17:28           ` joseph.maniaci
  0 siblings, 1 reply; 13+ messages in thread
From: Gyorgy Sarvari @ 2025-07-17 17:20 UTC (permalink / raw)
  To: yocto, joseph.maniaci, Quentin Schulz

On 7/17/25 18:48, joseph.maniaci via lists.yoctoproject.org wrote:
> Ah, I'm using a script to do this in a repeatable fashion, so I forgot
> that the last thing it does is
>  
> export BB_ENV_PASSTHROUGH_ADDITIONS="$BB_ENV_PASSTHROUGH_ADDITIONS
> ABC"    
>

This makes the variable available in the bitbake datastore (e.g. you can
reference it in recipes, or you can use d.getVar("ABC") in python), but
it won't make it available automatically as an environment variable. To
have it as an env var you are expected to export it, with "export ABC"
in the recipe, either in a task to make it available in that specific
task, or outside of tasks, to make it available in all tasks. (Or in a
global config file, like local.conf for example, to make  it available
for all tasks globally as env var)

Since you mention that it is available in the compile step, I wonder if
you have an explicit "export ABC" in the do_compile task.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [yocto] Environmental variable present in do_compile() {}, bitbake recipe -e, but is missing from do_configure() {} #bitbake
  2025-07-17 17:20         ` Gyorgy Sarvari
@ 2025-07-17 17:28           ` joseph.maniaci
  2025-07-17 18:16             ` joseph.maniaci
  0 siblings, 1 reply; 13+ messages in thread
From: joseph.maniaci @ 2025-07-17 17:28 UTC (permalink / raw)
  To: Gyorgy Sarvari, yocto

[-- Attachment #1: Type: text/plain, Size: 178 bytes --]

I must have at some point because after double checking the output of 'export' of do_compile, I no longer see it there as well....sorry for wasting your guys' time on this one.

[-- Attachment #2: Type: text/html, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [yocto] Environmental variable present in do_compile() {}, bitbake recipe -e, but is missing from do_configure() {} #bitbake
  2025-07-17 17:28           ` joseph.maniaci
@ 2025-07-17 18:16             ` joseph.maniaci
  2025-07-18  7:43               ` Gyorgy Sarvari
  0 siblings, 1 reply; 13+ messages in thread
From: joseph.maniaci @ 2025-07-17 18:16 UTC (permalink / raw)
  To: joseph.maniaci, yocto

[-- Attachment #1: Type: text/plain, Size: 1082 bytes --]

Okay, maybe one more question for the next poor soul that has the same-ish issue

Why does this work:

*** Prior to bitbake ***

export ABC="AAAAAAAAAAAAAAAHHHHHHHHHHHHHHH"
export BB_ENV_PASSTHROUGH_ADDITIONS="$BB_ENV_PASSTHROUGH_ADDITIONS ABC"

*** bitbake recipe ***
....
do_configure () {
export ABC=${ABC} && cmake_do_configure } <<<--- Obviously referencing and seeing ${ABC}
....

CMAKE configures and compiles successfully

but this doesn't

*** bitbake recipe ***
....
do_configure () {
cmake_do_configure <<<---  ${ABC} doesn't make it to cmake
}
....

*** cmakelists.txt ***

if ( NOT DEFINED ENV{ABC})
message (FATAL_ERROR "Undefined environmental variable: ABC \n " )
endif ()

*** bitbake output ***
....
| DEBUG: Executing shell function do_configure
....

*** cmake output ***
| CMake Error at CMakeLists.txt:12 (message):
|   Undefined environmental variable: ABC

Even doing something like the following makes it visible to CMAKE

SOME_VAR = "${ABC}"
do_configure () {
export ABC=${SOME_VAR} && cmake_do_configure
}

[-- Attachment #2: Type: text/html, Size: 2860 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [yocto] Environmental variable present in do_compile() {}, bitbake recipe -e, but is missing from do_configure() {} #bitbake
  2025-07-17 18:16             ` joseph.maniaci
@ 2025-07-18  7:43               ` Gyorgy Sarvari
  2025-07-18 15:16                 ` joseph.maniaci
  0 siblings, 1 reply; 13+ messages in thread
From: Gyorgy Sarvari @ 2025-07-18  7:43 UTC (permalink / raw)
  To: yocto, joseph.maniaci

On 7/17/25 20:16, joseph.maniaci via lists.yoctoproject.org wrote:
> Okay, maybe one more question for the next poor soul that has the
> same-ish issue
>  
> Why does this work:
>  
> *** Prior to bitbake ***
>  
> export ABC="AAAAAAAAAAAAAAAHHHHHHHHHHHHHHH"
> export BB_ENV_PASSTHROUGH_ADDITIONS="$BB_ENV_PASSTHROUGH_ADDITIONS ABC"
>  
> *** bitbake recipe ***
> ....
> do_configure () {
>     export ABC=${ABC} && cmake_do_configure } <<<--- Obviously
> referencing and seeing ${ABC}
> ....
>  
> CMAKE configures and compiles successfully
>  
> but this doesn't

Because of the extra export you added.

Adding ABC to BB_ENV_PASSTHROUGH_ADDITIONS will make the ${ABC} variable
available in the recipes - but only in the recipes, and not as an
environment variable.

When you write inside a task 'export ABC="${ABC}"' - this looks like
pure shell, a self-referencing tautological assignment: seems like it
says "create an env var called ABC and set it to the value of the ABC
env var"

But it's something else.

It goes through the bitbake parser first, and by the time it is
executed, it becomes 'export ABC="AAAAAAAAAAAAAAAHHHHHHHHHHHHHHH"' - the
original ${ABC} is nowhere to be found, because it's a bitbake variable
(just like SRC_URI, for example), not an env var, it was substituted
with the literal value of ${ABC}. And before executing that export
statement, the ABC env var doesn't exist in the build environment at all.

>  
> *** bitbake recipe ***
> ....
> do_configure () {
>     cmake_do_configure <<<---  ${ABC} doesn't make it to cmake
> }
> ....
>  
> *** cmakelists.txt ***
>  
> if( NOTDEFINEDENV{ABC})
>     message(FATAL_ERROR "Undefined environmental variable: ABC\n")
> endif()
>  
> *** bitbake output ***
> ....
> | DEBUG: Executing shell function do_configure
> ....
>  
> *** cmake output ***
> | CMake Error at CMakeLists.txt:12 (message): |   Undefined
> environmental variable: ABC
>  
>  
>  
> Even doing something like the following makes it visible to CMAKE
>  
> SOME_VAR = "${ABC}" do_configure () {   export ABC=${SOME_VAR} &&
> cmake_do_configure }
>  
>  
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#65679): https://lists.yoctoproject.org/g/yocto/message/65679
> Mute This Topic: https://lists.yoctoproject.org/mt/114193163/6084445
> Mute #bitbake:https://lists.yoctoproject.org/g/yocto/mutehashtag/bitbake
> Group Owner: yocto+owner@lists.yoctoproject.org
> Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [skandigraun@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [yocto] Environmental variable present in do_compile() {}, bitbake recipe -e, but is missing from do_configure() {} #bitbake
  2025-07-18  7:43               ` Gyorgy Sarvari
@ 2025-07-18 15:16                 ` joseph.maniaci
  2025-07-18 15:17                   ` joseph.maniaci
  2025-07-18 15:40                   ` Quentin Schulz
  0 siblings, 2 replies; 13+ messages in thread
From: joseph.maniaci @ 2025-07-18 15:16 UTC (permalink / raw)
  To: Gyorgy Sarvari, yocto

[-- Attachment #1: Type: text/plain, Size: 926 bytes --]

On Fri, Jul 18, 2025 at 01:43 AM, Gyorgy Sarvari wrote:

> 
> It goes through the bitbake parser first, and by the time it is
> executed, it becomes 'export ABC="AAAAAAAAAAAAAAAHHHHHHHHHHHHHHH"' - the
> original ${ABC} is nowhere to be found, because it's a bitbake variable
> (just like SRC_URI, for example), not an env var, it was substituted
> with the literal value of ${ABC}. And before executing that export
> statement, the ABC env var doesn't exist in the build environment at all.

Man, considering the quantity of search results telling users to use BB_ENV_PASSTHROUGH_ADDITIONS to accomplish what I'm doing, that really feels like something that should be highlighted in red, and bolded, in the documentation ( https://docs.yoctoproject.org/bitbake/bitbake-user-manual/bitbake-user-manual-ref-variables.html#term-BB_ENV_PASSTHROUGH_ADDITIONS ). Not to mention all of the CMAKE gotchas I've come across.

[-- Attachment #2: Type: text/html, Size: 1067 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [yocto] Environmental variable present in do_compile() {}, bitbake recipe -e, but is missing from do_configure() {} #bitbake
  2025-07-18 15:16                 ` joseph.maniaci
@ 2025-07-18 15:17                   ` joseph.maniaci
  2025-07-18 15:40                   ` Quentin Schulz
  1 sibling, 0 replies; 13+ messages in thread
From: joseph.maniaci @ 2025-07-18 15:17 UTC (permalink / raw)
  To: joseph.maniaci, yocto

[-- Attachment #1: Type: text/plain, Size: 89 bytes --]

Thank you so much though for that clarification, I'll definitely never forget that one.

[-- Attachment #2: Type: text/html, Size: 100 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [yocto] Environmental variable present in do_compile() {}, bitbake recipe -e, but is missing from do_configure() {} #bitbake
  2025-07-18 15:16                 ` joseph.maniaci
  2025-07-18 15:17                   ` joseph.maniaci
@ 2025-07-18 15:40                   ` Quentin Schulz
  1 sibling, 0 replies; 13+ messages in thread
From: Quentin Schulz @ 2025-07-18 15:40 UTC (permalink / raw)
  To: yocto, joseph.maniaci, Gyorgy Sarvari

Hi Joseph,

On 7/18/25 5:16 PM, joseph.maniaci via lists.yoctoproject.org wrote:
> On Fri, Jul 18, 2025 at 01:43 AM, Gyorgy Sarvari wrote:
> 
>>
>> It goes through the bitbake parser first, and by the time it is
>> executed, it becomes 'export ABC="AAAAAAAAAAAAAAAHHHHHHHHHHHHHHH"' - the
>> original ${ABC} is nowhere to be found, because it's a bitbake variable
>> (just like SRC_URI, for example), not an env var, it was substituted
>> with the literal value of ${ABC}. And before executing that export
>> statement, the ABC env var doesn't exist in the build environment at all.
> 
> Man, considering the quantity of search results telling users to use BB_ENV_PASSTHROUGH_ADDITIONS to accomplish what I'm doing, that really feels like something that should be highlighted in red, and bolded, in the documentation ( https://docs.yoctoproject.org/bitbake/bitbake-user-manual/bitbake-user-manual-ref-variables.html#term-BB_ENV_PASSTHROUGH_ADDITIONS ). Not to mention all of the CMAKE gotchas I've come across.
> 

Don't hesitate to send patches for the docs :)

The more time one spends working with BitBake the more difficult it is 
to write documentation with the "beginner" eye, so this kind of feedback 
and contribution is very much welcome!

Cheers,
Quentin


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2025-07-18 15:40 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-16 21:20 Environmental variable present in do_compile() {}, bitbake recipe -e, but is missing from do_configure() {} #bitbake joseph.maniaci
2025-07-17  9:46 ` [yocto] " Alexander Kanavin
2025-07-17 16:24   ` joseph.maniaci
2025-07-17 16:29     ` Quentin Schulz
2025-07-17 16:48       ` joseph.maniaci
2025-07-17 17:20         ` Gyorgy Sarvari
2025-07-17 17:28           ` joseph.maniaci
2025-07-17 18:16             ` joseph.maniaci
2025-07-18  7:43               ` Gyorgy Sarvari
2025-07-18 15:16                 ` joseph.maniaci
2025-07-18 15:17                   ` joseph.maniaci
2025-07-18 15:40                   ` Quentin Schulz
2025-07-17 16:27   ` joseph.maniaci

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).