ruby-dbi
On master branch
on branch ruby_21x
---
We must use version 0.1.0 of sax-machine as version 0.2.0 uses way too much memory. See
When porting to Ruby 2.1 I think we might be on the safer side by monkey-patching this stuff locally.
As withe the sax-parser the import_daily takes much longer then usual (and provoked an error), Zeno wants to revert the two commits and will never look again at the sax-machine. Done with commits Revert "Using sax-parser for text_info." and Revert "Updated to use sax-machine 0.2.1"
We start the conversion of oddb.org to Ruby 2.1.x. Some tasks are already mentioned in http://dev.ywesee.com/Choddb/Ruby20. We start replacing the library iconv which cannot be used with Ruby 2.1.x.
First installing Ruby 2.1.2 from src. Steps were
cd /opt/src git clone git@github.com:ruby/ruby.git cd ruby git checkout v2_1_2 autoconf ./configure make -j 8 sudo make install ruby -v ruby 2.1.2p95 (2014-05-08 revision 45867) [x86_64-linux]
These installed the following binaries into /usr/local/bin, ruby rdoc rake testrb ri irb erb
. Checking gem
gem list *** LOCAL GEMS *** bigdecimal (1.2.4) io-console (0.4.2) json (1.8.1) minitest (4.7.5) psych (2.0.5) rake (10.1.0) rdoc (4.1.0) test-unit (2.1.2.0) gem content bigdecimal /usr/local/lib/ruby/2.1.0/bigdecimal/jacobian.rb /usr/local/lib/ruby/2.1.0/bigdecimal/ludcmp.rb /usr/local/lib/ruby/2.1.0/bigdecimal/math.rb /usr/local/lib/ruby/2.1.0/bigdecimal/newton.rb /usr/local/lib/ruby/2.1.0/bigdecimal/util.rb /usr/local/lib/ruby/2.1.0/x86_64-linux/bigdecimal.so
The following files have an useage of iconv
./ext/fiparse/src/textinfo_hpricot.rb:2 ./ext/fiparse/test/minifi_test.rb:1 ./ext/fiparse/test/data/smj_05_2003.rb:2 ./src/plugin/minifi.rb:1 ./src/plugin/ydim.rb:3 ./src/plugin/csv_export.rb:5 ./src/plugin/oddbdat_export.rb:1 ./src/view/migel/result.rb:1 ./src/view/additional_information.rb:1 ./src/util/log.rb:3 ./src/util/oddbapp.rb:16 ./src/util/validator.rb:4 ./src/util/http.rb:2 ./src/util/html_parser.rb:3 ./test/test_util/http.rb:1 ./test/test_plugin/ydim.rb:4 ./test/test_plugin/csv_export.rb:2
Creating a git branch ruby_21x. Starting with trying to make /usr/local/bin/ruby test/test_plugin/csv_export.rb
pass.
But first we must install all needed Gems. Running bundle install --system
and verifying it with gem content sax-machine
to see that sax-machine.rb was installed into /usr/local/lib/ruby/gems/2.1.0/gems/sax-machine-0.2.1/lib/sax-machine.rb
. Now we get the expected failure.
niklaus@oddb-ci2 /v/w/oddb.org> sudo -u apache /usr/local/bin/ruby test/test_plugin/csv_export.rb /usr/local/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- iconv (LoadError) from /usr/local/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require' from /var/www/oddb.org/src/util/http.rb:11:in `<top (required)>' from /usr/local/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require' from /usr/local/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require' from /var/www/oddb.org/src/plugin/plugin.rb:6:in `<top (required)>' from /usr/local/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require' from /usr/local/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require' from test/test_plugin/csv_export.rb:13:in `<main>'
Fix that problem with commit Iconv: made test/test_plugin/csv_export.rb pass
Fixing more errors with iconv with the following commits:
Will check the following error later
ruby test/test_util/oddbapp.rb test/test_util/oddbapp.rb:10:in `require': cannot load such file -- syck (LoadError) from test/test_util/oddbapp.rb:10:in `<main>'
Removed pdf2txt gem and its uses (minifi, indications, fachinfo_pdf) with commits Removed pdf2txt and Removed pdf2txt. Part two
More fixes with
Running bundle exec rake test
we only have 5 failures and 1 error to fix.
Pushed
Hoping that they will pass on travis-ci.
Starting bin/oddbd on ci2 resulted in the following error
FEHLER: Relation »collection« existiert bereits /usr/local/lib/ruby/2.1.0/delegate.rb:392:in `__getobj__': not delegated (ArgumentError) from /usr/local/lib/ruby/2.1.0/delegate.rb:341:in `block in delegating_block' from /usr/local/lib/ruby/gems/2.1.0/gems/dbi-0.4.5/lib/dbi/handles/statement.rb:214:in `fetch' from /usr/local/lib/ruby/gems/2.1.0/gems/dbi-0.4.5/lib/dbi/handles/statement.rb:240:in `each' from /usr/local/lib/ruby/gems/2.1.0/gems/dbi-0.4.5/lib/dbi/handles/database.rb:130:in `block in select_all' from /usr/local/lib/ruby/gems/2.1.0/gems/dbi-0.4.5/lib/dbi/handles/database.rb:88:in `execute' from /usr/local/lib/ruby/gems/2.1.0/gems/dbi-0.4.5/lib/dbi/handles/database.rb:128:in `select_all' from /usr/local/lib/ruby/gems/2.1.0/gems/dbd-pg-0.3.9/lib/dbd/pg/database.rb:173:in `columns' from /usr/local/lib/ruby/gems/2.1.0/gems/dbi-0.4.5/lib/dbi/handles/database.rb:161:in `columns' from /usr/local/lib/ruby/gems/2.1.0/gems/odba-1.1.0/lib/odba/connection_pool.rb:39:in `block in method_missing' from /usr/local/lib/ruby/gems/2.1.0/gems/odba-1.1.0/lib/odba/connection_pool.rb:29:in `next_connection' from /usr/local/lib/ruby/gems/2.1.0/gems/odba-1.1.0/lib/odba/connection_pool.rb:38:in `method_missing' from /usr/local/lib/ruby/gems/2.1.0/gems/odba-1.1.0/lib/odba/storage.rb:526:in `setup' from /usr/local/lib/ruby/gems/2.1.0/gems/odba-1.1.0/lib/odba/cache.rb:473:in `setup' from bin/oddbd:25:in `<main>' loading testenvironment DEVELOPER_HOST = ch.oddb.apache.org DEVELOPER_MAIL = ngiger@ywesee.com disabling UPDATER
Okay. We must apply the patches for ruby-dbi row and column. Or we might better fix ruby-dbi to make it installable via bundler install --system
?
Patching did not help. Trying whether this error occurs also with ruby 2.0.0.
With Ruby 2.0.0 (ruby 2.0.0p481 (2014-05-08 revision 45876) [x86_64-linux]) I got the following error
var/www/oddb.org/src/view/drugs/resultlist.rb:24: warning: already initialized constant HtmlGrid::List::BACKGROUND_SUFFIX /usr/local/lib/ruby/gems/2.0.0/gems/htmlgrid-1.0.6/lib/htmlgrid/list.rb:34: warning: previous definition of BACKGROUND_SUFFIX was here could not find htmlgrid.so, falling back to pure-ruby class /usr/local/lib/ruby/gems/2.0.0/gems/odba-1.1.0/lib/odba/storage.rb:515:in `restore_named': undefined method `first' for nil:NilClass (NoMethodError) from /usr/local/lib/ruby/gems/2.0.0/gems/odba-1.1.0/lib/odba/cache.rb:297:in `block in fetch_named' from /usr/local/lib/ruby/gems/2.0.0/gems/odba-1.1.0/lib/odba/cache.rb:313:in `call' from /usr/local/lib/ruby/gems/2.0.0/gems/odba-1.1.0/lib/odba/cache.rb:313:in `fetch_or_do' from /usr/local/lib/ruby/gems/2.0.0/gems/odba-1.1.0/lib/odba/cache.rb:296:in `fetch_named' from /var/www/oddb.org/src/util/oddbapp.rb:1459:in `initialize' from bin/oddbd:42:in `new' from bin/oddbd:42:in `<main>'
When uncommenting the line in usr/util/oddbapp.rb which switches to use syck I get the following error
undefined method `to_ary' for nil:NilClass undefined method `to_ary' for nil:NilClass undefined method `to_ary' for nil:NilClass undefined method `to_ary' for nil:NilClass /usr/local/lib/ruby/gems/2.0.0/gems/dbi-0.4.5/lib/dbi/handles/statement.rb:214:in `fetch': undefined method `to_ary' for nil:NilClass (NoMethodError) from /usr/local/lib/ruby/gems/2.0.0/gems/dbi-0.4.5/lib/dbi/handles/statement.rb:240:in `each' from /usr/local/lib/ruby/gems/2.0.0/gems/dbi-0.4.5/lib/dbi/handles/database.rb:130:in `block in select_all' from /usr/local/lib/ruby/gems/2.0.0/gems/dbi-0.4.5/lib/dbi/handles/database.rb:88:in `execute' from /usr/local/lib/ruby/gems/2.0.0/gems/dbi-0.4.5/lib/dbi/handles/database.rb:128:in `select_all' from /usr/local/lib/ruby/gems/2.0.0/gems/dbd-pg-0.3.9/lib/dbd/pg/database.rb:173:in `columns' from /usr/local/lib/ruby/gems/2.0.0/gems/dbi-0.4.5/lib/dbi/handles/database.rb:161:in `columns' from /usr/local/lib/ruby/gems/2.0.0/gems/odba-1.1.0/lib/odba/connection_pool.rb:39:in `block in method_missing' from /usr/local/lib/ruby/gems/2.0.0/gems/odba-1.1.0/lib/odba/connection_pool.rb:29:in `next_connection' from /usr/local/lib/ruby/gems/2.0.0/gems/odba-1.1.0/lib/odba/connection_pool.rb:38:in `method_missing' from /usr/local/lib/ruby/gems/2.0.0/gems/odba-1.1.0/lib/odba/storage.rb:526:in `setup' from /usr/local/lib/ruby/gems/2.0.0/gems/odba-1.1.0/lib/odba/cache.rb:473:in `setup' from bin/oddbd:25:in `<main>'
Patched also the dbi files in /usr/local/lib/ruby/gems/2.0.0/gems/dbi-0.4.5
. But I still get the same errors
After a discussion with Zeno, I am trying to use https://github.com/caiofilipini/ruby-dbi/tree/ruby-2.0. Merged his changes into my master branch and committed Fixed running under ruby 2.1.2. After calling rake dbi:gem
called sudo /usr/local/bin/gem install pkg/dbi-0.4.6.gem
to install it. Ensured that I am working with syck. Now calling bin/oddbd
gets further and brings the error
FEHLER: Relation »target_id_oddb_package_name_with_size_company_name_and_ean13« existiert bereits process: Oddb (OddbApp) /usr/local/lib/ruby/gems/2.1.0/gems/odba-1.1.0/lib/odba/cache_entry.rb:49:in `block in odba_add_reference': undefined method `odba_id' for module `Kernel' (NameError) from /usr/local/lib/ruby/gems/2.1.0/gems/odba-1.1.0/lib/odba/cache_entry.rb:48:in `synchronize' from /usr/local/lib/ruby/gems/2.1.0/gems/odba-1.1.0/lib/odba/cache_entry.rb:48:in `odba_add_reference' from /usr/local/lib/ruby/gems/2.1.0/gems/odba-1.1.0/lib/odba/cache.rb:322:in `block (3 levels) in fetch_or_restore' from /usr/local/lib/ruby/gems/2.1.0/gems/odba-1.1.0/lib/odba/cache.rb:313:in `call' from /usr/local/lib/ruby/gems/2.1.0/gems/odba-1.1.0/lib/odba/cache.rb:313:in `fetch_or_do' from /usr/local/lib/ruby/gems/2.1.0/gems/odba-1.1.0/lib/odba/cache.rb:320:in `block (2 levels) in fetch_or_restore' from /usr/local/lib/ruby/gems/2.1.0/gems/odba-1.1.0/lib/odba/cache.rb:319:in `synchronize' from /usr/local/lib/ruby/gems/2.1.0/gems/odba-1.1.0/lib/odba/cache.rb:319:in `block in fetch_or_restore' from /usr/local/lib/ruby/gems/2.1.0/gems/odba-1.1.0/lib/odba/cache.rb:313:in `call' from /usr/local/lib/ruby/gems/2.1.0/gems/odba-1.1.0/lib/odba/cache.rb:313:in `fetch_or_do' from /usr/local/lib/ruby/gems/2.1.0/gems/odba-1.1.0/lib/odba/cache.rb:317:in `fetch_or_restore' from /usr/local/lib/ruby/gems/2.1.0/gems/odba-1.1.0/lib/odba/cache.rb:304:in `block in fetch_named' from /usr/local/lib/ruby/gems/2.1.0/gems/odba-1.1.0/lib/odba/cache.rb:313:in `call' from /usr/local/lib/ruby/gems/2.1.0/gems/odba-1.1.0/lib/odba/cache.rb:313:in `fetch_or_do' from /usr/local/lib/ruby/gems/2.1.0/gems/odba-1.1.0/lib/odba/cache.rb:296:in `fetch_named' from /var/www/oddb.org/src/util/oddbapp.rb:1459:in `initialize' from bin/oddbd:42:in `new' from bin/oddbd:42:in `<main>'
Also I had to patch /usr/local/lib64/ruby/2.1.0/csv.rb
with http://dev.ywesee.com/uploads/att/csv.rb.patch.20111123.txt. After inserting in /usr/local/lib/ruby/gems/2.1.0/gems/odba-1.1.0/lib/odba/cache_entry.rb
the line 49 return if object.class == ODDB::App
bin/oddbd run without problem and I was able to run bin/admin
and got the (expected) result when running
ch.oddb> registration('62630').name_base -> Xeljanz 5 mg
Accessing oddb-ci2 via http did not work. Did not see a clear error message in /var/log/apache/(error|access).log. Will continue tomorrow.