Monday, January 26, 2009

Problem with copyplist (caused by an Apple bug + Ruby macports install)

I was trying to build a copy of the example code EditableDetailView, and I was getting an error when the build tried to run copyplist: Building target “EditableDetailView” of project “EditableDetailView” with configuration “Debug”Checking DependenciesPBXCp build/Debug-iphonesimulator/EditableDetailView.app/appData.plist appData.plist cd /Users/jamesmoore/dev/EditableDetailView setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Developer/Library/PrivateFrameworks/DevToolsCore.framework/Resources/pbxcp -exclude .DS_Store -exclude CVS -exclude .svn -resolve-src-symlinks /Users/jamesmoore/dev/EditableDetailView/appData.plist /Users/jamesmoore/dev/EditableDetailView/build/Debug-iphonesimulator/EditableDetailView.appCopyPlistFile /Users/jamesmoore/dev/EditableDetailView/build/Debug-iphonesimulator/EditableDetailView.app/appData.plist appData.plist cd /Users/jamesmoore/dev/EditableDetailView setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Developer/Library/Xcode/Plug-ins/CoreBuildTasks.xcplugin/Contents/Resources/copyplist appData.plist --outdir /Users/jamesmoore/dev/EditableDetailView/build/Debug-iphonesimulator/EditableDetailView.apperror: can't exec '/Developer/Library/Xcode/Plug-ins/CoreBuildTasks.xcplugin/Contents/Resources/copyplist' (No such file or directory) The first check I did was to make sure I had copyplist somewhere on the system:
jamesmoore@james-moores-macbook-pro:~$ locate copyplist/Developer/Library/Xcode/Plug-ins/CoreBuildTasks.xcplugin/Contents/Resources/copyplist
That's not in my normal path, but I didn't expect it to be.And anyway, XCode's build is calling copyplist from a specific location anyway - it wants /Developer/Library/Xcode/Plug-ins/CoreBuildTasks.xcplugin/Contents/Resources/copyplist and doesn't care about the path. There's a file at /Developer/Library/Xcode/Plug-ins/CoreBuildTasks.xcplugin/Contents/Resources/copyplist and it looks fine. But when I try to run it, I get the same thing:
[james-moores-macbook-pro:~/dev/EditableDetailView] jamesmoore% /Developer/Library/Xcode/Plug-ins/CoreBuildTasks.xcplugin/Contents/Resources/copyplist/Developer/Library/Xcode/Plug-ins/CoreBuildTasks.xcplugin/Contents/Resources/copyplist: Command not found.
So I open the file, and see the problem immediately on line 1:
#!/usr/bin/ruby
Of course there's no /usr/bin/ruby - I do Ruby development, and since Apple ships a version of Ruby that was current back when dinosaurs roamed the earth, I install the macports version. And that goes in /opt/local/bin, not /usr/bin. It's an Apple bug - hardcoding the location of Ruby is wrong. The line should be:
#!/usr/bin/env ruby
The workaround is just to link the good Ruby to the old, bad location:
sudo ln -s /opt/local/bin/ruby /usr/bin/

1 comment:

joshuajnoble said...

Thanks for this! Saved me a bunch o trouble after installing 1.9.1 to /usr/local/bin