'Library not loaded: /opt/local/lib/libffi.5.dylib but I'm using homebrew
I'm trying to run guard on Mac OS X Lion(XCode 4.3+OSX GCC Installer+Homebrew)
Error message:
Library not loaded: /opt/local/lib/libffi.5.dylib
I have no /opt/local directory since I'm not using MacPorts but Homebrew
I tried brew install libffi, which was successful, but the gem still doesn't work.
I also have tried uninstalling and reinstalling the gem without success.
Problem is also occurring on OSX 10.9 (Mavericks) with apple-gcc42 installed.
I have also tried telling gem about the presence of libffi as follows:
gem install ffi:1.0.7 -- --with-ldflags='-L/usr/local/opt/libffi/lib'
Solution 1:[1]
I'm using rvm, and I resolved it by reinstalling the ffi gem
gem uninstall ffi
gem install ffi ##or inside rails project folder run bundle install
Solution 2:[2]
I think this is best explained as a compatibility issue between Mac OS X and older versions of the ffi gem. That is why in some cases simply uninstalling and reinstalling the gem can work.
In my case ffi version 1.0.7 was specified in a project's Gemfile. My tests failed with Library not loaded: /opt/local/lib/libffi.5.dylib on that version, but if I tried latest version 1.9.3, it installed and worked without any fuss.
I was lucky and the need for that restriction on the project was placed years ago and no longer appears to be a requirement. So in the end I moved forward with later version of ffi gem.
I suspect there may be a way to get version 1.0.7 happily installed and working on OS X 10.9.2, but I do not know what that might be.
Solution 3:[3]
I have ended up in this situation after uninstalling MacPorts (I thought homebrew will be enough, but doesn't seem so). It stopped my cocoapods from updating/installing.
To make it work like a charm, I did:
$ sudo port install libffi
Solution 4:[4]
With otool and install_name_tool, you may fix the dependency problem. See Creating working dylibs for detail.
Solution 5:[5]
I encountered the same problem. Finally, I tried reinstall libffi:
brew reinstall libffi
and everything works.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | dotcomXY |
| Solution 2 | Neil Slater |
| Solution 3 | igraczech |
| Solution 4 | Yanhao |
| Solution 5 | Ireina |
