Bug 4505 - bitbake parses wrong PATH environment variable
Summary: bitbake parses wrong PATH environment variable
Status: RESOLVED NOTABUG
Alias: None
Product: BitBake
Classification: Build System, Metadata & Runtime
Component: bitbake (show other bugs)
Version: unspecified
Hardware: x86 x86_64
: Medium major
Target Milestone: 1.5
Assignee: Richard Purdie
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2013-05-16 17:14 UTC by Felipe Ferreri Tonello
Modified: 2013-06-07 19:08 UTC (History)
2 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Felipe Ferreri Tonello 2013-05-16 17:14:04 UTC
Bitbake is parsing wrong my PATH variable.
$ echo $PATH
/home/felipe/hd2/projects/metadata-poky/poky/scripts:/home/felipe/hd2/projects/metadata-poky/poky/bitbake/bin:/home/felipe/bin:/home/felipe/bin:/usr/lib64/qt-3.3/bin:/usr/lib64/ccache:/usr/local/bin:/usr/bin:/bin:/usr/games:/usr/local/sbin:/usr/sbin:/opt/t32/bin/pc_linux64


$ bitbake image
Pseudo is not present but is required, building this first before the main build
ERROR:  OE-core's config sanity checker detected a potential misconfiguration.
    Either fix the cause of this error or at your own risk disable the checker (see sanity.conf).
    Following is the list of potential problems / advisories:

    PATH contains '.' or '' (empty element), which will break the build, please remove this.
Parsed PATH is ['/home/felipe/projects/metadata-poky/poky/scripts', '/home/felipe/hd2/projects/build/tmp/sysroots/x86_64-linux/usr/bin/armv7a-vfp-neon-willow-linux-gnueabi', '/home/felipe/hd2/projects/build/tmp/sysroots/g2/usr/bin/crossscripts', '/home/felipe/hd2/projects/build/tmp/sysroots/x86_64-linux/usr/sbin', '/home/felipe/hd2/projects/build/tmp/sysroots/x86_64-linux/usr/bin', '/home/felipe/hd2/projects/build/tmp/sysroots/x86_64-linux/sbin', '/home/felipe/hd2/projects/build/tmp/sysroots/x86_64-linux//bin', '']
Please install the following missing utilities: GNU make,C Compiler (gcc),C++ Compiler (g++),patch,diffstat,makeinfo,git,bzip2,tar,gzip,gawk,chrpath,wget,cpio

ERROR: Execution of event handler 'check_sanity_eventhandler' failed

$ bitbake --version
BitBake Build Tool Core version 1.18.0, bitbake version 1.18.0

I'm using bitbake that comes with poky 9.0

When I run 'BB_ENV_WHITELIST="PATH $BB_ENV_WHITELIST" bitbake image' it works.
Comment 1 Richard Purdie 2013-05-24 15:27:22 UTC
I don't understand how this is happening and I may need your help in debugging this. Its a surprising bug since I'd have expected lots of reports of this issue if it were common and we just have this one report so it has to be something specific about your environment. Which shell are you using?

Looking at the code, bitbake/lib/bb/utils.py does:

def approved_variables():
    """
    Determine and return the list of whitelisted variables which are approved
    to remain in the envrionment.
    """
    approved = []
    if 'BB_ENV_WHITELIST' in os.environ:
        approved = os.environ['BB_ENV_WHITELIST'].split()
        approved.extend(['BB_ENV_WHITELIST'])
    else:
        approved = preserved_envvars()

i.e. if BB_ENV_WHITELIST isn't set, it calls preserved_envvars() and PATH is in the list that returns (or should be).

So I don't understand how your work around can make any difference.

bitbake.conf does a PATH_prepend and we're only seeing the prepended code. Since the prepend ends with a :, that triggers the sanity warning. FOr some reason PATH therefore isn't making it into the datastore from the environment.

This all implies that preserved_envvars() is returning a bad set of data but looking at the function, its very simple and should be deterministic.

Are you able to do simple python debugging and have a look at what         preserved_envvars() is returning and try and track this down a bit further based on this information?
Comment 2 Richard Purdie 2013-05-30 14:37:58 UTC
Need help to debug this...
Comment 3 Felipe Ferreri Tonello 2013-06-03 18:14:45 UTC
(In reply to comment #1)
> I don't understand how this is happening and I may need your help in
> debugging this. Its a surprising bug since I'd have expected lots of reports
> of this issue if it were common and we just have this one report so it has
> to be something specific about your environment. Which shell are you using?

I'm using BASH.

> 
> Looking at the code, bitbake/lib/bb/utils.py does:
> 
> def approved_variables():
>     """
>     Determine and return the list of whitelisted variables which are approved
>     to remain in the envrionment.
>     """
>     approved = []
>     if 'BB_ENV_WHITELIST' in os.environ:
>         approved = os.environ['BB_ENV_WHITELIST'].split()
>         approved.extend(['BB_ENV_WHITELIST'])
>     else:
>         approved = preserved_envvars()
> 
> i.e. if BB_ENV_WHITELIST isn't set, it calls preserved_envvars() and PATH is
> in the list that returns (or should be).

Maybe that's the problem because I use BB_ENV_WHITELIST for other variables, but I didn't set PATH.

> 
> So I don't understand how your work around can make any difference.
> 
> bitbake.conf does a PATH_prepend and we're only seeing the prepended code.
> Since the prepend ends with a :, that triggers the sanity warning. FOr some
> reason PATH therefore isn't making it into the datastore from the
> environment.
> 
> This all implies that preserved_envvars() is returning a bad set of data but
> looking at the function, its very simple and should be deterministic.
> 
> Are you able to do simple python debugging and have a look at what        
> preserved_envvars() is returning and try and track this down a bit further
> based on this information?

Yes, I will do that and post the results.
Comment 4 Richard Purdie 2013-06-04 09:58:11 UTC
(In reply to comment #3)
> (In reply to comment #1)
> Maybe that's the problem because I use BB_ENV_WHITELIST for other variables,
> but I didn't set PATH.

This is indeed the problem. If you use BB_ENV_WHITELIST, you are expected to explicitly specify which variables you want to whitelist so this is working as intended.

If you just want to add your own variables, use BB_ENV_EXTRAWHITE instead. This other variable sounds like the one you want in this case.
Comment 5 Felipe Ferreri Tonello 2013-06-07 19:08:09 UTC
Yes. That solves the problem.

But The thing is that on poky 8.0 I didn't have this.