Gieta Laksmana
  • Blog
  • Profile
  • Projects
    • VR World Arcade
    • Punch For Fun
    • Spectrum
    • Dimension Battle
  • Resume

xcodebuild couldn't posix_spawn: error 7

7/8/2017

0 Comments

 
​Tldr: path to the working directory was too long
 
When building an older project with xcodebuild, I suddenly started getting this error:

** INTERNAL ERROR: Uncaught exception **
Uncaught Exception: Couldn't posix_spawn: error 7
Stack:
  0   __exceptionPreprocess (in CoreFoundation)
  1   objc_exception_throw (in libobjc.A.dylib)
  2   +[NSException raise:format:] (in CoreFoundation)
  3   -[NSConcreteTask launchWithDictionary:] (in Foundation)
  4   __46-[IDEShellScriptExecutionActionOperation main]_block_invoke_2.229 (in IDEStandardExecutionActionsCore)
  5   ___DVTAsyncPerformBlockOnMainRunLoop_block_invoke (in DVTFoundation)
  6   __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ (in CoreFoundation)
  7   __CFRunLoopDoBlocks (in CoreFoundation)
  8   __CFRunLoopRun (in CoreFoundation)
  9   CFRunLoopRunSpecific (in CoreFoundation)
10   CFRunLoopRun (in CoreFoundation)
11   -[Xcode3CommandLineBuildTool _buildWithTimingSection:] (in Xcode3Core)
12   -[Xcode3CommandLineBuildTool run] (in Xcode3Core)
13  0x000000010fe00202 (in xcodebuild)
14   start (in libdyld.dylib)

After much googling and investigating, I found that:
  • xcodebuild calls posix_spawn()
  • posix_spawn() calls exec()
  • exec() fail with error 7 – E2BIG: Argument list too long
  • running getconf ARG_MAX from the terminal shows that the maximum argument list was 262144 bytes
 
Originally I ran the script from ~/jenkinsroot/some/very/long/path/to/the/project/directory
and the individual files that are being compiled lies way deeper on the folder structure. Which made me to believe that when xcodebuild tries to give the files full path as an argument to posix_spawn, the length exceeds 262144 bytes

It works when I move the project root directory to ~/shorter/path
 
helpful links:
http://lxr.free-electrons.com/source/include/uapi/asm-generic/errno-base.h#L14
http://www.in-ulm.de/~mascheck/various/argmax/
http://pubs.opengroup.org/onlinepubs/009695399/functions/posix_spawn.html
http://pubs.opengroup.org/onlinepubs/009695399/functions/exec.html

 
now I can have a peaceful weekend :)
0 Comments

    Archives

    September 2018
    August 2018
    July 2018
    September 2017
    July 2017
    November 2016
    October 2016
    September 2016
    June 2016
    May 2016
    March 2016

    Categories

    All
    Shenanigans
    Software Engineering
    Swift
    Vr
    Xcode

    RSS Feed

Powered by Create your own unique website with customizable templates.