Bug 3271

Summary: Better error message when bitbake is run from the 'wrong' directory
Product: [Build System, Metadata & Runtime] BitBake Reporter: Evadeflow <evadeflow>
Component: bitbakeAssignee: Richard Purdie <richard.purdie>
Status: VERIFIED FIXED QA Contact:
Severity: enhancement    
Priority: Low CC: bluelightning, corneliux.stoicescu, jessica.zhang, poky.bs.watcher, poky.watcher
Version: unspecified   
Target Milestone: 1.5   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Done (doc changes complete)
Attachments:
Description Flags
Bitbake 'Hello World!' example
none
Fix error msg when bblayers.conf not found none

Description Evadeflow 2012-10-10 16:29:10 UTC
I was just trying to follow along with Patrick Turley's 'Hello World' example (see https://lists.yoctoproject.org/pipermail/yocto/2012-October/012193.html) and I accidentally forgot to switch to the build directory before invoking bitbake.  The error I got (with bitbake master) was:

> % ../bitbake/bin/bitbake a 
> The BBPATH variable is not set
> DEBUG: Removed the following variables from the environment: http_proxy, CVS_RSH, LANG, SHLVL, LD_LIBRARY_PATH, EDITOR, SUDO_USER, USERNAME, PROMPT, PYTHONPATH, SUDO_UID, RPROMPT, _, SUDO_COMMAND, SUDO_GID, OLDPWD, MAIL
DEBUG: UI 'knotty' does not require extra cache!

A simple oversight like this must happen a dozen times daily here on Planet Earth. Once you've become accustomed to bitbake's quirks, I'm sure this isn't the slightest bit confusing; but to a novitiate like myself, it almost feels like I'm being hazed. Don't Haze Me, Bro'! :-}

There are probably valid reasons that bitbake can't detect with 100% accuracy that the user has simply forgotten to change to the correct directory. But it should be able to make a good guess and offer corrective advice. If there's a directory named 'build*' in the current directory with a 'conf' sub-folder, how about saying:

> The BBPATH variable is not set
> (Perhaps you intended to run bitbake from /home/evadeflow/projects/foo/build?)

Even for out-of-source builds, there's got to be some way of emitting a more helpful error message. BBPATH is not set? Heck, NOTHING is set. Can't bitbake detect this and say:

> The BBPATH variable is not set
> (Did you invoke bitbake from the wrong directory?)

Oh, yes--yes, I did. Thank you!
Comment 1 Stoicescu Cornel 2012-10-11 14:46:22 UTC
Hello.

I just ran bitbake from the poky directory and I got: 
"
Unable to find conf/bblayers.conf
BitBake must be run from within your build diectory: /home/cornel/Yocto/poky/build
"

Please give us the exact steps to reproduce this.

Thank you
Cornel.
Comment 2 Evadeflow 2012-10-11 16:08:04 UTC
Created attachment 885 [details]
Bitbake 'Hello World!' example

This example is the one that caused me to file the bug. But I don't think it's needed to reproduce the behavior:

> poky|master|% pwd
> /home/evadeflow/projects/poky
> poky|master|% echo "Note: I have not sourced oe-init-build-env"
> Note: I have not sourced oe-init-build-env
> poky|master|% echo $PATH
> /home/evadeflow/bin:/home/evadeflow/jdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
> poky|master|% ./bitbake/bin/bitbake foo
> The BBPATH variable is not set
> DEBUG: Removed the following variables from the environment: http_proxy, CVS_RSH, LANG, SHLVL, LD_LIBRARY_PATH, EDITOR, SUDO_USER, USERNAME, PROMPT, PYTHONPATH, SUDO_UID, RPROMPT, _, SUDO_COMMAND, SUDO_GID, OLDPWD, MAIL
> DEBUG: UI 'knotty' does not require extra cache!

Not a big deal, I just think that error message could be better. :-)
Comment 3 Paul Eggleton 2012-10-12 13:43:22 UTC
You should not be running bin/bitbake but instead scripts/bitbake, which is a wrapper that ensures everything is set up correctly. bitbake as we use it in OE-Core/Poky is really intended be run from the wrapper script so I don't think we really support doing otherwise (until the wrapper script goes away, which it will do at some point in the future).
Comment 4 Evadeflow 2012-10-12 16:00:16 UTC
(In reply to comment #3)
> You should not be running bin/bitbake but instead scripts/bitbake...

The message is a lot clearer in this case:

> bitbake_hello% ../poky/scripts/bitbake foo
> Unable to find conf/bblayers.conf
> BitBake must be run from within your build directory

Since I was following along with someone's 'Hello, World' example, I
just did what it recommended. If the wrapper script can emit such a
lucid error message, why can't bitbake/bin say something more helpful
than:

> The BBPATH variable is not set

I completely understand that this is an extremely low priority item.
You can assign this bug to me if you want. It would be a good
introduction for me, and maybe I'll discover along the way that
improving the error output is actually quite involved. I'm just trying
to be as critical of bitbake's user experience as I am about my own
company's products. A bad first impression can turn off would-be users
who are just 'doing a drive-by', and mind share is everything.
Comment 5 Evadeflow 2012-10-12 16:40:03 UTC
Created attachment 887 [details]
Fix error msg when bblayers.conf not found

Humbly submit this is small improvement...
Comment 6 Richard Purdie 2013-06-28 09:35:47 UTC
Patch merged to master: http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=624160af6e5429c9f08b201bc6599dc8dcb62c3f sorry about the delay in doing so, didn't notice there was a patch here.

Incidentally the wrapper script is now gone so this is a bigger issue.
Comment 7 Stoicescu Cornel 2013-10-02 12:59:51 UTC
Verified in:
poky master:2f64fae60b3f61a2c45dc9e5314d2d16b1e64605

Please look at this bug for tips on using bitbake from any directory: bug 5063