Command /bin/sh failed with exit code 2

4,099 views
Skip to first unread message

Jason Hawkins

unread,
Apr 8, 2011, 4:24:51 PM4/8/11
to RestKit
Hello. After following the installation instructions (found at
https://github.com/twotoasters/RestKit/tree/0.9) for Xcode 4.x (Git
Submodule), I run into this build error:

Scripts/Protect.command: line 3:
: command not found
Scripts/Protect.command: line 6:
: command not found
Scripts/Protect.command: line 16: syntax error: unexpected end of file
Command /bin/sh failed with exit code 2

The problem happens consistently on my machine (MacBookPro3,1, 2.4,
4GB, 10.6.7 running Xcode 4.0.1), but not on another machine
(MacBook3,2 Air, 2.13 GHz, 4GB, 10.6.7 running Xcode 4.0). If the same
setup instructions are followed using the other machine there are no
errors, and everything runs great. In fact, all of the test projects
we've created work just fine on my machine if they were first created
on the other.

A test project that I created on my machine can be found here:
https://github.com/jasonhawkins/SuperAwesomeApp

We've tried going over each installation step carefully to make sure
we aren't just making a simple mistake, but the problem persists.

Any help would be greatly appreciated. Thanks.


Jason

Blake Watters

unread,
Apr 8, 2011, 7:38:36 PM4/8/11
to res...@googlegroups.com, Jason Hawkins
Jason -

I just built your project successfully on my machine without issue. Can you do a build and send me the full build log output so I can take a peak? An easy way to get it all is using xcodebuild:

xcodebuild -workspace SuperAwesomeApp.xcodeproj/project.xcworkspace -scheme SuperAwesomeApp -sdk iphonesimulator4.3
Blake Watters
Two Toasters | CTO

Jason Hawkins

unread,
Apr 8, 2011, 10:50:17 PM4/8/11
to RestKit
Hi Blake, thanks for taking a look at this so quickly.

I uploaded the build log here: http://cl.ly/123g3m0i0U4523161R1Y I
hope that helps. Thanks again for taking the time to do this.


Jason
>  *Blake Watters*

Blake Watters

unread,
Apr 9, 2011, 5:01:37 PM4/9/11
to res...@googlegroups.com, Jason Hawkins
Jason -

This is totally weird. Is there anything special about your machine's setup? Are you using an alternate set of shell utilities (i.e. installed core-utils via Fink/Macports, etc)? If you can, grab a copy of the built script files from /Users/Jason/Library/Developer/Xcode/DerivedData/project-byapqxsvbztevcasqhkpmtubidvm/Build/Intermediates/RestKit.build/Debug-iphonesimulator/RestKit.build/

Also try disabling the Protect Copied Headers build task (change /bin/sh to /bin/echo). I am curious if the rsync script will execute successfully for you (i.e. is the problem with that script in particular or generally with scripts).

- Blake
Blake Watters

Jason Hawkins

unread,
Apr 10, 2011, 3:12:24 PM4/10/11
to RestKit
Hey Blake,

As far as I know there's nothing special or weird about my machine's
setup. I've had it for several years now, though, and have tried a few
different development environments (I'm still relatively new to
programming). I do have Rails installed on my machine, but used them
Gem installer to get it, not MacPorts. I checked my system for
MacPorts anyway and didn't find anything — the same for Fink.

I grabbed the build scripts you asked for and uploaded them here:
http://cl.ly/0T2k22143O0N2u0w1W1a

I tried disabling the Protect Copied Headers build task, but I don't
know if I did that right. I changed:

#!/bin/sh
rm -f "${TARGET_BUILD_DIR}/include/RestKit/RestKit.h"
cp "${SOURCE_ROOT}/Code/RestKit.h" "${TARGET_BUILD_DIR}/include/
RestKit"

to

#!/bin/echo
rm -f "${TARGET_BUILD_DIR}/include/RestKit/RestKit.h"
cp "${SOURCE_ROOT}/Code/RestKit.h" "${TARGET_BUILD_DIR}/include/
RestKit"

Was that correct? Thanks again for your help.


Jason


On Apr 9, 5:01 pm, Blake Watters <bl...@twotoasters.com> wrote:
> Jason -
>

Jason Hawkins

unread,
Apr 11, 2011, 5:20:38 PM4/11/11
to RestKit
Hey again Blake,

So I have an update. Larry and I were able to get RestKit working
after commenting out everything in both
CopyHeadersToLegacyBuildDir.command and Protect.command. I'm not sure
if that was the smartest or safest thing to do, but I can build and
run projects now. :)

Is that what you meant about disabling the Protect and Copied
Headers?


Jason

On Apr 9, 5:01 pm, Blake Watters <bl...@twotoasters.com> wrote:
> Jason -
>

Blake Watters

unread,
Apr 12, 2011, 10:02:13 AM4/12/11
to res...@googlegroups.com, Jason Hawkins
Jason -

If you are using derived data build directory on Xcode 4 that should work fine without issue. It is a real head-scratcher why your environment can't run the scripts though -- they're pretty vanilla.

- Blake
Blake Watters

Jason Hawkins

unread,
Apr 14, 2011, 12:30:39 AM4/14/11
to RestKit
Hey Blake,

Shortly after I posted that last message everything went south again.
I got about a dozen build errors and decided it was time for the
nuclear approach. So I just spent the day wiping my system and
reinstalling everything. I'm happy to report that the problem no
longer exists :)

So in the end I'm guessing it had little or nothing to do with your
framework, but I really appreciate the time you put into helping me on
this. Thank you.


Jason

Blake Watters

unread,
Apr 14, 2011, 9:14:06 AM4/14/11
to res...@googlegroups.com, Jason Hawkins
I think I am hearing that I can now officially add "Wipe your system and reinstall everything" to the list of solutions for build failures in the FAQ :-)
Blake Watters

Nazar Hussain

unread,
Aug 28, 2012, 6:35:44 AM8/28/12
to res...@googlegroups.com
This post saved my life. Thanks a lot. It was really wiered, As i switch to zsh XCode start giving this error. As i switch back to sh it works fine. 
Reply all
Reply to author
Forward
0 new messages