brianmario / charlock_holmes

Character encoding detection, brought to you by ICU
MIT License
1.04k stars 141 forks source link

LoadError libicudata.64.dylib with 0.7.7 #156

Open OneDivZero opened 4 years ago

OneDivZero commented 4 years ago

Installed as described in readme on latest OSX, installation passed without errors, but now rails does not work any more.

LoadError: dlopen(/Users/xxx/Projects/DTAG/td-wowi-shop-backend/vendor/bundle/ruby/2.5.0/gems/charlock_holmes-0.7.7/lib/charlock_holmes/charlock_holmes.bundle, 9): Library not loaded: /usr/local/opt/icu4c/lib/libicudata.64.dylib

Referenced from: /Users/xxx/Projects/DTAG/td-wowi-shop-backend/vendor/bundle/ruby/2.5.0/gems/charlock_holmes-0.7.7/lib/charlock_holmes/charlock_holmes.bundle

Reason: image not found - /Users/xxx/Projects/DTAG/td-wowi-shop-backend/vendor/bundle/ruby/2.5.0/gems/charlock_holmes-0.7.7/lib/charlock_holmes/charlock_holmes.bundle

ivandenysov commented 3 years ago

This might happen after you upgrade your icu4c. For example after brew upgrade. To fix it run bundle pristine charlock_holmes

I believe that this suggestion should be a part of the error message

stanhu commented 1 year ago

This happens quite frequently to us. https://github.com/brianmario/charlock_holmes/pull/164 would add an --enable-static option so that icu4c upgrades don't break charlock_holmes.

stanhu commented 4 months ago

I think we can close this issue now that charlock_holmes 0.7.9 supports the --enable-static option:

gem install charlock_holmes -- --enable-static

This will work for macOS, but not for Debian/Ubuntu since they don't ship a static library compiled with -fPIC.

MurapureddiNag commented 1 week ago

If you’re having trouble installing charlock_holmes on an M3 Mac, try this:

Install a compatible ICU version:

brew install icu4c@74

Install the gem with the ICU path specified:

gem install charlock_holmes -v 0.7.7 -- --with-icu-dir=$(brew --prefix icu4c@74)

This links charlock_holmes to a compatible ICU version and should fix installation issues on Apple Silicon(Apple M3 Pro).

KieranP commented 6 days ago

Just ran into these issues after running brew upgrade. It installed icu4c@76, which evidently is not supported. Downgrading to @74 as per @MurapureddiNag comment above worked well. Thanks.

Also, --enable-static as mentioned earlier in this ticket does not work, so sticking with dynamic linking for now.

stanhu commented 3 days ago

I've had no issues building charlock_holmes with icu4c@75 or icu4c@76 on Ruby 3.2.5. --enable-static also works fine.

What errors are you seeing?

stanhu commented 3 days ago

It's entirely possible the issue I ran into with Go in https://github.com/golang/go/issues/70209 is applicable here. The change in https://github.com/unicode-org/icu/commit/199bc827021ffdb43b6579d68e5eecf54c7f6f56 caused icu-uc to be in the Requires.private for libicu-i18n.pc:

Requires.private: icu-uc

We might need to add --static to the pkg-config command to pick up icu-uc.

However, I'm not seeing an issue:

% otool -L tmp/arm64-darwin23/stage/lib/charlock_holmes/charlock_holmes.bundle
tmp/arm64-darwin23/stage/lib/charlock_holmes/charlock_holmes.bundle:
    /Users/stanhu/.local/share/mise/installs/ruby/3.3.5/lib/libruby.3.3.dylib (compatibility version 3.3.0, current version 3.3.5)
    /opt/homebrew/opt/icu4c@76/lib/libicudata.76.dylib (compatibility version 76.0.0, current version 76.1.0)
    /opt/homebrew/opt/icu4c@76/lib/libicuuc.76.dylib (compatibility version 76.0.0, current version 76.1.0)
    /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.12)
    /opt/homebrew/opt/icu4c@76/lib/libicui18n.76.dylib (compatibility version 76.0.0, current version 76.1.0)
    /opt/homebrew/opt/icu4c@76/lib/libicuio.76.dylib (compatibility version 76.0.0, current version 76.1.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1351.0.0)
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1800.101.0)
stanhu commented 2 days ago

Actually, it seems charlock_holmes already adds all the required libraries here: https://github.com/brianmario/charlock_holmes/blob/1c14a3fd5b08f629bba7ba478f8644a5296932bc/ext/charlock_holmes/extconf.rb#L33-L35

That explains the latest version works fine for me. I don't know what errors people are getting.