It can happen with macos that your Rails project using the charlock_holmes gem throws an error like this:
/Users/iwan/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/bootsnap-1.15.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require': dlopen(/Users/iwan/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/charlock_holmes-0.7.7/lib/charlock_holmes/charlock_holmes.bundle, 0x0009): Library not loaded: '/opt/homebrew/opt/icu4c/lib/libicudata.71.dylib' (LoadError)
Referenced from: '/Users/iwan/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/charlock_holmes-0.7.7/lib/charlock_holmes/charlock_holmes.bundle'
Reason: tried: '/opt/homebrew/opt/icu4c/lib/libicudata.71.dylib' (no such file), '/usr/local/lib/libicudata.71.dylib' (no such file), '/usr/lib/libicudata.71.dylib' (no such file), '/opt/homebrew/Cellar/icu4c/72.1/lib/libicudata.71.dylib' (no such file), '/usr/local/lib/libicudata.71.dylib' (no such file), '/usr/lib/libicudata.71.dylib' (no such file) - /Users/iwan/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/charlock_holmes-0.7.7/lib/charlock_holmes/charlock_holmes.bundle
from /Users/iwan/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/bootsnap-1.15.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
from /Users/iwan/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/charlock_holmes-0.7.7/lib/charlock_holmes.rb:1:in `<main>'
...
This behavior can happen when brew is updated (and this happens when a new formula is installed: by default it does an overall update of all previously installed formulas), and in particular when
icu4cis updated.The
charlock_holmesgem includes a C and C++ part that is compiled when you install the gem. Before compiling, however, a check is performed on theicu4clibrary installed, and its position is written in theMakefiledocument in which the steps to be performed in the compilation are defined.At this point if
icu4chas been updated for example from version 71 to 72.1, the compiled C code will no longer be able to access the old version of the library, which is no longer present. Hence the error.The solution? Reinstall
charlock_holmes: