I got a bundle install issue recently. A few members from other team are having the environment issue and couldn’t get it solved in a whole day. Finally, I found the solution and I feel it is necessary for me document it and it is a good chance to learn more about MacOS SDK and how ruby works(a separate post).
Issue
I want to install the ruby gem in a local folder with command bundle install --binstubs=.bundle/bin --path=.bundle/vendor/bundle
.
File Structure
└── cucumber
├── .bundle
│ └── config
├── Gemfile
└── Gemfile.lock
Gemfile file:
1 | source "https://rubygems.org" |
And you will get this error:
1 | ... |
problem
This is caused by improperly installed SDK. Run the solution found in stackoverflow is not helpful.(https://stackoverflow.com/questions/29859413/bundle-install-error-failed-to-build-gem-native-extension-nio4r-gem)
And installing the xcode will not help.
This command will success
gem install eventmachine -- --with-cppflags=-I/usr/local/opt/openssl/include
but run thisbundle config --local build.eventmachine --with-cppflags=-I/usr/local/opt/openssl/include
to configure the bundle will not work.Some developer didn’t configure their
rbenv
properly and it leads to using the system default ruby when they run bundle command.
Solution
we need forcely update the SDK.
1 | Update them from Software Update in System Preferences or run: |