I use macports (not homebrew) as my package manager on my mac for some software that I need to use with Ruby on Rails. From time to time, I’ll get an error like this when I try to start a rails server.
/Users/maryh/Software/rubies/2.5.7/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require': dlopen(/Users/maryh/Software/rubies/2.5.7/lib/ruby/gems/2.5.0/gems/ffi-1.11.3/lib/ffi_c.bundle, 9): Library not loaded: /opt/local/lib/libffi.6.dylib (LoadError) Referenced from: /Users/maryh/Software/rubies/2.5.7/lib/ruby/gems/2.5.0/gems/ffi-1.11.3/lib/ffi_c.bundle Reason: image not found - /Users/maryh/Software/rubies/2.5.7/lib/ruby/gems/2.5.0/gems/ffi-1.11.3/lib/ffi_c.bundle
Almost always, this is due to the fact that a package in macports was upgraded. In this example, /opt/local/lib/libffi.6.dylib is missing. But if I look in /opt/local/lib, the file libffi.7.dylib is there. So what I want to do is downgrade back to the version I want.
The first step is to list the versions installed for a given package.
be:~ $ sudo port installed libffi The following ports are currently installed: libffi @3.2.1_0 libffi @3.3_1 (active)
Here it’s easy, and I just want to go back to the previous version.
be:~ $ sudo port activate email@example.com_0 ---> Deactivating libffi @3.3_1 ---> Cleaning libffi ---> Activating libffi @3.2.1_0 ---> Cleaning libffi be:~ $ sudo port installed libffi The following ports are currently installed: libffi @3.2.1_0 (active) libffi @3.3_1 be:~ $ ll /opt/local/lib/libffi.6.dylib -rwxr-xr-x 1 root admin 33024 Oct 28 2019 /opt/local/lib/libffi.6.dylib
The deactivate command is run automatically. Though I could also run port deactivate package as a separate step if I needed to.