Bug 9506

Summary: bitbake-layers: show-layers throws exception when can't find layer in bblayers.conf
Product: [Build System, Metadata & Runtime] BitBake Reporter: Humberto Ibarra <humberto.ibarra.lopez>
Component: bitbakeAssignee: Humberto Ibarra <humberto.ibarra.lopez>
Status: VERIFIED WONTFIX QA Contact:
Severity: normal    
Priority: Medium+ CC: jose.perez.carranza, leonardo.sandoval.gonzalez, poky.bs.watcher, poky.watcher, richard.purdie
Version: 2.1   
Target Milestone: 2.2 M1   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description Humberto Ibarra 2016-04-21 20:44:06 UTC
When a wrong path to a layers is found in bblayers.conf, the command bitbake-layers show-layers throws an exception. This should either ignore the failing layer or show a more graceful error message to the user.


humberto@yctb03:~/poky/build-test> echo "BBLAYERS += \"/foo/path\"" >> conf/bblayers.conf;  bitbake-layers show-layers
ERROR: Traceback (most recent call last):
  File "/home/humberto/poky/bitbake/lib/bb/cookerdata.py", line 179, in wrapped
    return func(fn, *args)
  File "/home/humberto/poky/bitbake/lib/bb/cookerdata.py", line 203, in parse_config_file
    return bb.parse.handle(fn, data, include)
  File "/home/humberto/poky/bitbake/lib/bb/parse/__init__.py", line 113, in handle
    return h['handle'](fn, data, include)
  File "/home/humberto/poky/bitbake/lib/bb/parse/parse_py/ConfHandler.py", line 124, in handle
    abs_fn = resolve_file(fn, data)
  File "/home/humberto/poky/bitbake/lib/bb/parse/__init__.py", line 136, in resolve_file
    raise IOError(errno.ENOENT, "file %s not found" % fn)
IOError: [Errno 2] file /foo/path/conf/layer.conf not found

ERROR: Unable to parse /foo/path/conf/layer.conf: [Errno 2] file /foo/path/conf/layer.conf not found
Comment 1 Humberto Ibarra 2016-05-04 19:49:50 UTC
Have been checking this and have a few comments to make:

-About the problem

To me it does look like something we need to solve. Stack traces can be confusing and I believe that those should only be shown when we do not know what is the exact failure.

Here, we know that the layer conf file can't be found, we should be failing gracefully. This situation is not much different from issuing "bitbake-layers add-layer <name>" when trying to add a layer that does not exist, and that command fails gracefully with no stack trace.

This error message shouldn't behave differently from that one.

-About Implementation:

The solution to this is not as easy as handling the error in the bitbake-layers script though. Unlike the add-layer subcommand, show-layers relies on cookerdata to handle the parsing of config files, so the fix must be inside a script used by many parts of the code.

Still wondering about the best way to proceed here. Adding a sys.exit under a conditional solves the problem, but the abrupt exit does not look like the ideal solution. Throwing a specific exception could work but I see no advantage in dealing with separate exceptions for each simple case like this one.

I will continue looking into this.
Comment 3 Humberto Ibarra 2016-05-11 20:02:49 UTC
Sent patch v2

http://lists.openembedded.org/pipermail/bitbake-devel/2016-May/007433.html
Comment 4 Humberto Ibarra 2016-05-12 19:19:15 UTC
Sent patch v3

http://lists.openembedded.org/pipermail/bitbake-devel/2016-May/007456.html
Comment 5 Humberto Ibarra 2016-05-13 15:31:17 UTC
It has been noted that this will be solved at a higher level with the current migration to python3.
Comment 6 Leonardo Sandoval Gonzalez 2016-05-13 16:30:54 UTC
(In reply to comment #5)
> It has been noted that this will be solved at a higher level with the
> current migration to python3.

I do not get it. The patch that you sent is valid either on python2 or 3. So, in my opinion, it should be merged on bitbake master.

Leo
Comment 7 Jose Perez C 2016-06-20 15:03:42 UTC
Working as expected 

Validated on : commit 7b9e1f5ad8a427356f2ec516b1718138a7d3c64e


**********************
ERROR: Layer directory '/foo/path' does not exist! Please check BBLAYERS in /home/jgperezc/work/YoctoProject/poky_test/build/conf/bblayers.conf