Buildwrapper on macOS works on local system, but throws error on CI

until now I was executing the buildwrapper for sonarQube locally on my mac and it was running fine without any problem. Now I moved it to our CI system where it also runs on a mac Buildagent. But on the agent it crashes with an unknown reason:

[Step 2/7] perl: posix_spawn: /private/tmp/sonarsource-build-wrapper-cache-504/usr/bin/perl5.18: Unknown error: -1

the log file of the wrapper just ends with exit code 2:

Tue May 04 18:57:42 2021: executable: </private/tmp/sonarsource-build-wrapper-cache-504/usr/bin/perl>
Tue May 04 18:57:42 2021: argv[0]:
Tue May 04 18:57:42 2021: argv[1]: </usr/local/bin/lcov>
Tue May 04 18:57:42 2021: argv[2]: <–directory>
Tue May 04 18:57:42 2021: argv[3]: <.>
Tue May 04 18:57:42 2021: argv[4]: <–zerocounters>
Tue May 04 18:57:42 2021: skipping process with pid: 92550
Tue May 04 18:57:42 2021: finalizing json file
Tue May 04 18:57:42 2021: returned with code: 2

I use to call the wrapper in the following way:

sonarqube/build-wrapper-macosx-x86/build-wrapper-macosx-x86 --out-dir sonarqubewrapperlogs make -j10

has anyone an idea what could be wrong here? Running it without the wrapper works fine.

Hi @the_frank ,

there is an issue with Perl 5.18, could you try to install a different version of Perl before calling build-wrapper? i.e. with brew install perl and checking output of perl --version before build-wrapper invocation.

Thanks Massimo, I installed a newer version of perl and was using this with success. What I’m still not really clear about is the fact that my local machine and the build server was using the exact same perl version 5.18.4 with different results.

Hi @the_frank,

thank you for the update.

different macOS version perhaps?

No, both have the exact same MacOS version (latest security patch 10.15.7) and the perl version used was the bundled one with MacOS.

Ok, interesting. I created CPP-3111 to track the issue.

1 Like

I got the same error, even I update the perl version to 5.34.

When I compile using Mac EC2 connected with Jenkins, I got a similar error:
/bin/sh -c /tmp/workspace/test/derivedataPath/Build/Intermediates.noindex/
perl: posix_spawn: /private/tmp/sonarsource-build-wrapper-cache-501/usr/bin/perl5.18: Unknown error: -1
perl: posix_spawn: /private/tmp/sonarsource-build-wrapper-cache-501/usr/bin/perl5.18: Unknown error: -1

Inside the shell script:

find “${SRCROOT}” ( -name “.h" -or -name ".m” -or -name “.swift" ) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($TAGS).$|($ERRORTAG).*$” | perl -p -e “s/($TAGS)/ warning: $1/”| perl -p -e “s/($ERRORTAG)/ error: $1/”

so I did ls -la. perl5.18 not exist

  • ls -la /private/tmp/sonarsource-build-wrapper-cache-501/usr/bin
    total 528
    drwxr-xr-x 8 ec2-user wheel 256 Jun 25 19:01 .
    drwxr-xr-x 3 ec2-user wheel 96 Jun 15 22:24 …
    -rwxr-xr-x 1 ec2-user wheel 47136 Oct 30 2020 egrep
    -rwxr-xr-x 1 ec2-user wheel 65040 Oct 30 2020 find
    -rwxr-xr-x 1 ec2-user wheel 42864 Oct 30 2020 perl
    -rwxr-xr-x 1 ec2-user wheel 31696 Oct 30 2020 which
    -rwxr-xr-x 1 ec2-user wheel 41456 Oct 30 2020 xargs
    -rwxr-xr-x 1 ec2-user wheel 31488 Oct 30 2020 xcodebuild

Seems like the script called perl and would call “/private/tmp/sonarsource-build-wrapper-cache-501/usr/bin/perl5.18” instead of the system perl

when I do ‘perl -version’ in the same Mac EC2 environment, it reply:

  • perl -version

This is perl 5, version 34, subversion 0 (v5.34.0) built for darwin-thread-multi-2level

Hi @wcheung_nd ,

review the default setting of PATH. Maybe, before launching it you can try to force it, with something like:

export PATH=/usr/local/bin:$PATH

@mpaladin Thanks. seems like Jenkins launching a new shell would omit the /usr/local/bin, as soon as I export that into $PATH the wrapper seems able to find the system perl.

1 Like

Great, thank you for the update @wcheung_nd .

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.