akihikodaki / cld3-ruby

cld3-ruby is an interface of Compact Language Detector v3 (CLD3) for Ruby.
Apache License 2.0
78 stars 22 forks source link

fix issue for missing libcld3.bundle in ruby 3.2.0 #40

Closed josh-m-sharpe closed 1 year ago

josh-m-sharpe commented 1 year ago

it seems that ruby 3.2.0 added some build directory cleaning after native extensions are built and this removes ext/cld3/libcld3.bundler leading to this error:

Could not open library libcld3.bundle'

According to https://github.com/rubygems/rubygems/issues/6205 the "fix" is to reference the file inside the lib directory

josh-m-sharpe commented 1 year ago

So I think this works. I was able to build the extension locally, and then the gem. I included it in my app with:

gem 'cld3', path: "../path/to/cld3-ruby/intermediate"

..and it seems to work. Yay?

josh-m-sharpe commented 1 year ago
rake spec
cp -p ext/cld3/ext/src/script_span/fixunicodevalue.cc intermediate/ext/cld3
cp -p ext/cld3/ext/src/script_span/fixunicodevalue.h intermediate/ext/cld3
cp -p ext/cld3/ext/src/script_span/generated_entities.cc intermediate/ext/cld3
cp -p ext/cld3/ext/src/script_span/generated_ulscript.cc intermediate/ext/cld3
cp -p ext/cld3/ext/src/script_span/generated_ulscript.h intermediate/ext/cld3
cp -p ext/cld3/ext/src/script_span/getonescriptspan.cc intermediate/ext/cld3
cp -p ext/cld3/ext/src/script_span/getonescriptspan.h intermediate/ext/cld3
cp -p ext/cld3/ext/src/script_span/integral_types.h intermediate/ext/cld3
cp -p ext/cld3/ext/src/script_span/offsetmap.cc intermediate/ext/cld3
cp -p ext/cld3/ext/src/script_span/offsetmap.h intermediate/ext/cld3
cp -p ext/cld3/ext/src/script_span/port.h intermediate/ext/cld3
cp -p ext/cld3/ext/src/script_span/stringpiece.h intermediate/ext/cld3
cp -p ext/cld3/ext/src/script_span/text_processing.cc intermediate/ext/cld3
cp -p ext/cld3/ext/src/script_span/text_processing.h intermediate/ext/cld3
cp -p ext/cld3/ext/src/script_span/utf8acceptinterchange.h intermediate/ext/cld3
cp -p ext/cld3/ext/src/script_span/utf8prop_lettermarkscriptnum.h intermediate/ext/cld3
cp -p ext/cld3/ext/src/script_span/utf8repl_lettermarklower.h intermediate/ext/cld3
cp -p ext/cld3/ext/src/script_span/utf8scannot_lettermarkspecial.h intermediate/ext/cld3
cp -p ext/cld3/ext/src/script_span/utf8statetable.cc intermediate/ext/cld3
cp -p ext/cld3/ext/src/script_span/utf8statetable.h intermediate/ext/cld3
rm -rf intermediate/ext/cld3/script_span
cd intermediate && bundle config path vendor/bundle && bundle install
Using concurrent-ruby 1.2.0
Using i18n 1.12.0
Using minitest 5.17.0
Using tzinfo 2.0.6
Using activesupport 7.0.4.2
Using ast 2.4.2
Using bundler 2.4.2
Using ffi 1.15.5
Using cld3 3.5.0 from source at `.`
Using diff-lcs 1.5.0
Using language_server-protocol 3.17.0.3
Using rb-fsevent 0.11.2
Using rb-inotify 0.10.1
Using listen 3.8.0
Using parallel 1.22.1
Using parser 3.2.0.0
Using rainbow 3.1.1
Using rbs 2.6.0
Using rspec-support 3.11.1
Using rspec-core 3.11.0
Using rspec-expectations 3.11.1
Using rspec-mocks 3.11.2
Using rspec 3.11.0
Using unicode-display_width 2.4.2
Using terminal-table 3.0.2
Using steep 1.0.2
Bundle complete! 4 Gemfile dependencies, 26 gems now installed.
Bundled gems are installed into `./vendor/bundle`
cd intermediate/ext/cld3 && ruby extconf.rb
creating Makefile
make -C intermediate/ext/cld3 install sitearchdir=../../lib sitelibdir=../../lib
linking shared-object libcld3.bundle
/opt/homebrew/opt/coreutils/bin/ginstall -c -m 0755 libcld3.bundle ../../lib
cd intermediate && bundle exec rspec
I, [2023-02-09T14:15:04.488971 #63665]  INFO -- : Setting up hooks for ::CLD3
I, [2023-02-09T14:15:04.489079 #63665]  INFO -- rbs: Installing runtime type checker in CLD3...
I, [2023-02-09T14:15:04.495202 #63665]  INFO -- : Setting up hooks for ::CLD3::NNetLanguageIdentifier
I, [2023-02-09T14:15:04.495236 #63665]  INFO -- rbs: Installing runtime type checker in CLD3::NNetLanguageIdentifier...
I, [2023-02-09T14:15:04.495455 #63665]  INFO -- rbs: Setting up method hook in #initialize...
I, [2023-02-09T14:15:04.495763 #63665]  INFO -- rbs: Setting up method hook in #find_language...
I, [2023-02-09T14:15:04.495942 #63665]  INFO -- rbs: Setting up method hook in #find_top_n_most_freq_langs...
I, [2023-02-09T14:15:04.496113 #63665]  INFO -- rbs: Setting up method hook in #convert_result...
I, [2023-02-09T14:15:04.496833 #63665]  INFO -- : Setting up hooks for ::CLD3::TaskContextParams
I, [2023-02-09T14:15:04.496843 #63665]  INFO -- rbs: Installing runtime type checker in CLD3::TaskContextParams...
I, [2023-02-09T14:15:04.497155 #63665]  INFO -- : Setting up hooks for ::CLD3
I, [2023-02-09T14:15:04.497164 #63665]  INFO -- rbs: Installing runtime type checker in CLD3...
.....

Finished in 0.01195 seconds (files took 0.51852 seconds to load)
5 examples, 0 failures
akihikodaki commented 1 year ago

This is invalid as described at: https://github.com/akihikodaki/cld3-ruby/issues/37#issuecomment-1367861386

Referring to the lib directory can also be problematic in the future as the binary in the directory is stated to be removed anyway: https://github.com/rubygems/rubygems/commit/e07dba09231a5182cab8a00094cbc261cd1ed0fc