This is a very terse post to record a problem/solution for Cocoapods on High Sierra.
I have a build process that involves running cocoapods and xcodebuild on the command line. Some time ago, I installed rvm in an attempt to fix a build error. It ended up not fixing the error, but I kept it installed because it seemed like a nice thing to be able to easily switch between ruby versions. However, xcodebuild
and its sub-tools are picky about using the system ruby, so before running xcodebuild, I would always have to switch back to the system ruby using rvm use system
. This was an inconvenience, but it wasn’t hard to do, so I just endured.
Some time later, I upgraded to High Sierra, which broke my system ruby. Running ruby
would give an error like
dyld: Library not loaded: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/libruby.2.0.0.dylib
Referenced from: /usr/local/bin/ruby
Reason: image not found
Abort trap: 6
This seems to be because High Sierra upgraded its ruby to 2.3.0, but rvm some things still referenced the old 2.0 installation, which had been removed. In trying to resolve this situation I first uninstalled rvm – because I didn’t seem to be helping anything and could possibly be hurting things:
rvm implode
After doing this, I still received the error message above. I then noticed that I had two ruby binaries on my Path: /usr/local/bin/ruby
and /usr/bin/ruby
. The former referenced the old 2.0 libs, while the latter seemed to correctly reference the new location. So, I deleted the former:
sudo rm /usr/local/bin/ruby
And things almost started working. When I tried installing cocoapods again with:
sudo gem install cocoapods
I received “Permission denied” messages. I needed to do
sudo gem install -n /usr/local/bin cocoapods
And, voila!, things magically start working again.