I have compiled a custom sqlite3 executable to enable support for ICU (collation rules: sorting with accents, etc. for utf-8).
I use rvm and the ruby sqlite gem seems to use:
~/.rvm/gems/ruby-1.9.3-p392@project/gems/sqlite3-1.3.7/lib/sqlite3/sqlite3_native.so
My db creation code requires the collation rules so when I use the sqlite gem I get an error:
/home/user/.rvm/gems/ruby-1.9.3-p392@project/gems/sqlite3-1.3.7/lib/sqlite3/database.rb:91:in `initialize': SQLite3::SQLException: no such function: icu_load_collation (Sequel::DatabaseError)
...which makes sense since the default sqlite does not have the collation rules built-in.
When I use my custom sqlite3 executable directly everything works fine.
My questions are the following:
Is there a way to get a debian/ubundu package of sqlite3 with ICU support already built-in? I couldn't find any.
If (1) is not possible, do I need to compile sqlite3 and create a static library instead of an executable?
If (2) is possible, how can I make the change properly? I use bundler and deploy in another machine.
Is there another way to make the sqlite gem see my native executable (or the .so if (2) is possible).
Thank you in advance,
K.
I have finally made it work. To install a gem while compiling the native extensions (like ICU support for sqlite) with specific options one needs to do:
$ gem install sqlite3 --verbose -- \
--with-opt-include=/home/user/local/lib/sqlite-autoconf-3071602/ \
--with-opt-lib=/home/user/local/lib/sqlite-autoconf-3071602/.libs \
--with-cflags='-O3 -DSQLITE_ENABLE_ICU' \
--with-cppflags=`icu-config --cppflags` \
--with-ldflags=`icu-config --ldflags`
Whatever goes after the two 'empty' dashes "--" are parameters going to the build process of the gem. This assumes that the src distribution of sqlite3 was uncompressed at: /home/user/local/lib/sqlite-autoconf-3071602/
Now, since I use bundler I wanted this to be automated. To do that one can use the following command:
bundle config build.sqlite3 --with-opt-include=/home/user/local/lib/sqlite-autoconf-3071602/ ...
... which means that whenever sqlite3 gem is installed pass the following options in the build process. That creates a ~/.bundle/config
file with an entry for that gem, e.g. the file would have:
BUNDLE_BUILD__SQLITE3: --with-opt-include=/home/karask/local/lib/sqlite-autoconf-3071602/ --with-opt-lib=/home/karask/local/lib/sqlite-autoconf-3071602/.libs --with-cflags='-O3 -DSQLITE_ENABLE_ICU' --with-cppflags=`icu-config --cppflags` --with-ldflags=`icu-config --ldflags`
However, that wasn't working properly for me. For some reason the entry in ~/.bundle/config
wasn't correct. I tried quoting and escaping in several combinations with no luck. At the end I create this entry manually in my deployment process (a shell script) by adding the following:
$ mkdir ~/.bundle
$ echo "BUNDLE_BUILD__SQLITE3: --with-opt-include=/home/user/local/lib/sqlite-autoconf-3071602/ --with-opt-lib=/home/user/local/lib/sqlite-autoconf-3071602/.libs --with-cflags='-O3 -DSQLITE_ENABLE_ICU' --with-cppflags=`icu-config --cppflags` --with-ldflags=`icu-config --ldflags`" > ~/.bundle/config