Bug 10331

Summary: build.py exception: FileNotFoundError: [Errno 2] No such file or directory
Product: [Build System, Metadata & Runtime] BitBake Reporter: Juro Bystricky <juro.bystricky>
Component: bitbakeAssignee: Juro Bystricky <juro.bystricky>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Undecided CC: poky.bs.watcher, poky.watcher
Version: 2.2   
Target Milestone: ---   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)
Attachments:
Description Flags
Avoid exception when calling os.getcwd() none

Description Juro Bystricky 2016-09-26 20:21:06 UTC
Created attachment 3442 [details]
Avoid exception when calling os.getcwd()

Under some rather unique conditions I encountered the following error:

ERROR: nativesdk-libgcc-initial-6.2.0-r0 do_populate_sysroot: Error executing a python function in exec_python_func() autogenerated:

The stack trace of python calls that resulted in this exception/failure was:
File: 'exec_python_func() autogenerated', lineno: 2, function: <module>
     0001:
 *** 0002:do_populate_sysroot(d)
     0003:
File: '/data/master-zephyr/poky/meta/classes/staging.bbclass', lineno: 213, function: do_populate_sysroot
     0209:            problems.add(task)
     0210:    return problems
     0211:
     0212:python do_populate_sysroot () {
 *** 0213:    bb.build.exec_func("sysroot_stage_all", d)
     0214:    bb.build.exec_func("sysroot_strip", d)
     0215:    for f in (d.getVar('SYSROOT_PREPROCESS_FUNCS', True) or '').split():
     0216:        bb.build.exec_func(f, d)
     0217:    pn = d.getVar("PN", True)
File: '/data/master-zephyr/poky/bitbake/lib/bb/build.py', lineno: 264, function: exec_func
     0260:            exec_func_python(func, d, runfile, cwd=adir, pythonexception=pythonexception)
     0261:        else:
     0262:            exec_func_shell(func, d, runfile, cwd=adir)
     0263:
 *** 0264:    if oldcwd and os.getcwd() != oldcwd:
     0265:        try:
     0266:            bb.warn("Task %s changed cwd to %s" % (func, os.getcwd()))
     0267:            os.chdir(oldcwd)
     0268:        except:
Exception: FileNotFoundError: [Errno 2] No such file or directory



The reason for the exception is we are running the command os.getcwd() from a directory that no longer exist.

(The attachment fixes this)
Comment 1 Juro Bystricky 2016-09-26 21:20:37 UTC
patch sent to the mailing list:
http://lists.openembedded.org/pipermail/openembedded-core/2016-September/126949.html