Xcode's ipatool depends on gems installed on system ruby, crashes with bundler, rbenv or rvm

Number:rdar://28726736 Date Originated:11-Oct-2016 05:48 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode 8.0
Classification:Serious Bug Reproducible:Always
Felix Krause

The Ruby script "ipatool" bundled in Xcode tries to `require` third party Ruby gems, which causes issues when using a different Ruby environment (e.g. bundler, rvm or rbenv). 

There are 3 third party gems required by the `ipatool` (located in ".../Xcode.app/Contents/Developer/usr/bin/ipatool")

- [CFPropertyList](https://github.com/ckruse/CFPropertyList)
- [sqlite3](https://github.com/sparklemotion/sqlite3-ruby)
- [digest](https://rubygems.org/gems/digest)

Steps to Reproduce:
1. Setup a ruby script that just shells out to `xcodebuild` to archive the app, e.g.
xcodebuild -exportArchive -exportOptionsPlist '/tmp/my.plist' -archivePath /Users/.../something.xcarchive  -exportPath '/tmp/output' 
2. Create a Gemfile in the same directory
3. Run `bundle install`
4. Run `bundle exec [ruby script]`

Expected Results:
The `ipatool` should either properly bundle the required third party gems, or unset the environment variables.

Depending on third party gems, without actually locking their version is risky. Users can easily uninstall system gems, or update them, which may lead to a broken Xcode. 

Actual Results:
The `ipatool` throws an exception that it can't `require` the third party gem 'cfpropertylist'

2016-10-11 03:05:13 +0000  /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:15:in `require': cannot load such file -- cfpropertylist (LoadError)
  from /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:15:in `<main>'
2016-10-11 03:05:13 +0000 [MT] /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool exited with 1
2016-10-11 03:05:13 +0000 [MT] ipatool JSON: (null)

Xcode 8

You can find more information about how to debug and reproduce the issue on GitHub: https://github.com/fastlane/fastlane/issues/6495.

Workaround we're using is to unset certain Ruby environment variables, see https://github.com/fastlane/fastlane/blob/master/gym/lib/assets/wrap_xcodebuild/xcbuild-safe.sh




Any news here?

No news on this?

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!