brianmario / charlock_holmes

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

Uncaught exception: libicudata.so.72: cannot open shared object file: No such file or directory #163

Open apospielov opened 1 year ago

apospielov commented 1 year ago

Trying to run my project on ubuntu 22. ruby 3.1.2 getting this:

Fast Debugger (ruby-debug-ide 3.0.0.beta.5, debase 3.0.0.beta.5, file filtering is supported, block breakpoints supported, smart steps supported, obtaining return values supported, partial obtaining of instance variables supported) listens on 0.0.0.0:34977 Uncaught exception: libicudata.so.72: cannot open shared object file: No such file or directory - /home/andrey/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/charlock_holmes-0.7.7/lib/charlock_holmes/charlock_holmes.so /home/andrey/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/charlock_holmes-0.7.7/lib/charlock_holmes.rb:1:in require' /home/andrey/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/charlock_holmes-0.7.7/lib/charlock_holmes.rb:1:in<top (required)>' /home/andrey/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.24/lib/bundler/runtime.rb:60:in require' /home/andrey/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.24/lib/bundler/runtime.rb:60:inblock (2 levels) in require' /home/andrey/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.24/lib/bundler/runtime.rb:55:in each' /home/andrey/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.24/lib/bundler/runtime.rb:55:inblock in require' /home/andrey/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.24/lib/bundler/runtime.rb:44:in each' /home/andrey/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.24/lib/bundler/runtime.rb:44:inrequire' /home/andrey/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.24/lib/bundler.rb:186:in require' /home/andrey/firstup/governor/config/application.rb:17:in<top (required)>' /home/andrey/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/railties-7.0.4/lib/rails/commands/server/server_command.rb:137:in require' /home/andrey/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/railties-7.0.4/lib/rails/commands/server/server_command.rb:137:inblock in perform'

:90:in `tap' /home/andrey/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/railties-7.0.4/lib/rails/commands/server/server_command.rb:134:in `perform' /home/andrey/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run' /home/andrey/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command' /home/andrey/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch' /home/andrey/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/railties-7.0.4/lib/rails/command/base.rb:87:in `perform' /home/andrey/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/railties-7.0.4/lib/rails/command.rb:48:in `invoke' /home/andrey/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/railties-7.0.4/lib/rails/commands.rb:18:in `' /home/andrey/firstup/governor/bin/rails:4:in `require' /home/andrey/firstup/governor/bin/rails:4:in `' /home/andrey/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/debase-3.0.0.beta.5/lib/debase.rb:211:in `load_protect' /home/andrey/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/debase-3.0.0.beta.5/lib/debase.rb:211:in `debug_load' Process finished with exit code 0

the file /home/andrey/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/charlock_holmes-0.7.7/lib/charlock_holmes/charlock_holmes.so is present there.

How to fix?

stanhu commented 1 year ago

I think you need to run gem pristine charlock_holmes. I suspect icu4c was upgraded by Homebrew. https://github.com/brianmario/charlock_holmes/pull/164 attempts to avoid this problem by statically linking the libraries.

stanhu commented 1 week ago

FYI, I published static_holmes with #164. You need to pass --enable-static in one of two ways:

gem install static_holmes -- --enable-static

Alternatively, add this to your Gemfile:

source 'https://rubygems.org'

gem 'static_holmes', '~> 0.7.11', require: 'charlock_holmes'
bundle config build.static_holmes "--enable-static"
bundle install

This only works with macOS out-of-the-box because most distributions (at least Ubuntu and Debian) don't ship with a static library compiled with -fPIC.

mensfeld commented 3 days ago
gem pristine charlock_holmes

ain't working on 22.04 0 as of now no idea how to make it work

stanhu commented 2 days ago

@mensfeld What happens if you uninstall and install again?

gem uninstall charlock_holmes
gem install charlock_holmes
mensfeld commented 2 days ago

@stanhu same. I basically had to compile icu myself and move it to a proper location to make it work.

stanhu commented 2 days ago

@mensfeld What errors are you seeing?

mensfeld commented 2 days ago

@stanhu I no longer see any because I compiled icu and moved it where charlock expected it but when I had it, I pretty much had the same complaint as the first person here (just for libicudata.so.73):

Uncaught exception: libicudata.so.73: cannot open shared object file: No such file or directory

My ubuntu 22.04 by default has icu up to 66. No idea how and why it wanted 73. Ubuntu 22.04 by default ain't shipped with such fresh one.

stanhu commented 2 days ago

Strange. It sounds like charlock_holmes found libicudata.so.73 somewhere in your system at some point, and now it's gone.

mensfeld commented 2 days ago

@stanhu yeah I know. But I looked into the sources and apt references and I was not able to find any. I literally scanned my whole system for the so icu files. Nothing of that version. Reinstall, rebuild wasn't helping. What helped was me compiling the icu 73. Since I have a fix and it seems to be my machine specific oh well :shrug:

FYI I have a second machine with ubuntu 20.04 (not 22.04) and there is no issue there.

stanhu commented 1 day ago

@mensfeld I wonder if you had a .pc lying around that referenced version 73.

What does pkg-config --cflags --libs-only-l icu-i18n return?

mensfeld commented 1 day ago
pkg-config --cflags --libs-only-l icu-i18n
-I/home/mencio/.miniconda3/include -licui18n -licuuc -licudata
stanhu commented 1 day ago

Oh, what about pkg-config --libs-only-L icu-i18n?

I wonder if this suggests you have a copy of ICU inside /home/mencio/.miniconda3. Perhaps some Python wheel installed a copy?