In recently released Xcode CLI tools 5.1, Apple has changed clang not to accept unknown CLI options. This causes gem installation failures for gems with C extensions when using Chef Client Mac OSX Omnibus Packages.
The reason of this issue is that during the build process, ruby is configured with compiler options that are incompatible with the latest version of clang. When installing rubygems with C extensions this leads to errors like:
clang: error: unknown argument: '-R/opt/chef/embedded/lib' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
Workaround for this issue is to downgrade the errors to warnings. For this you can set below environment variable when installing a gem to the ruby embedded in Chef Client omnibus packages:
CONFIGURE_ARGS="--with-ldflags='-Wno-error=unused-command-line-argument-hard-error-in-future'" \
/opt/chef/embedded/bin/gem install knife-ec2
Similarly if you are installing gems via bundler you can configure the same environment variable with:
bundle config build.nokogiri --with-cflags="-Wno-error=unused-command-line-argument-hard-error-in-future"
Note: You can check your Xcode CLI Tools version with this command. If it's 5.1.X you might run into this issue in your gem installs.
>> pkgutil --pkg-info=com.apple.pkg.CLTools_Executables
package-id: com.apple.pkg.CLTools_Executables
version: 5.1.0.0.1.1393561416
volume: /
location: /
install-time: 1395089845
groups: ...
We are making a few changes in order to resolve this issue:
- We will start building Chef Client omnibus packages on 10.8 with Xcode CLI Tools 5.1. This package will be tested on Mac OSX 10.8 & 10.9 and it will be installed on these platforms when
install.shis used. - Apple didn't ship Xcode CLI Tools 5.1 for Mac OSX 10.7. Therefore we will still build packages on that platform using the older Xcode CLI Tools.
- Also during this investigation we found out that Apple silently EOL'ed 10.6. We are planning to remove support for this platform in the medium term so we recommend upgrading if you're running Chef on 10.6.
Note that installing 10.7 packages on later versions of Mac OSX might result in gem installation issues.
We will be working with our awesome Release Engineering team on these changes. Meanwhile if you run into these issues and if the workaround doesn't work for you drop us a line.