Milan Pudasini Milan Pudasini - 6 months ago 39
Ruby Question

error while trying to run the server after adding the gem "tesseract-ocr" rails 4

I was trying to make an OCR application and after adding the gem to the gemfile "tesseract-ocr" running the server, it shows the following error:

/Users/brijesh/.rvm/gems/ruby-2.2.1/gems/ffi-1.9.10/lib/ffi/library.rb:133:in `block in ffi_lib': Could not open library '/var/folders/1z/tn3pp1b90fvb5dh_7t2_kt2c0000gn/T/.ffi-inline-501/55a18292181116dcb44d5cd16f74500e379c7f92.dylib': dlopen(/var/folders/1z/tn3pp1b90fvb5dh_7t2_kt2c0000gn/T/.ffi-inline-501/55a18292181116dcb44d5cd16f74500e379c7f92.dylib, 5): Library not loaded: /usr/local/lib/libjpeg.8.dylib (LoadError)
Referenced from: /usr/local/lib/liblept.4.dylib
Reason: Incompatible library version: liblept.4.dylib requires version 13.0.0 or later, but libjpeg.8.dylib provides version 12.0.0
from /Users/brijesh/.rvm/gems/ruby-2.2.1/gems/ffi-1.9.10/lib/ffi/library.rb:100:in `map'
from /Users/brijesh/.rvm/gems/ruby-2.2.1/gems/ffi-1.9.10/lib/ffi/library.rb:100:in `ffi_lib'
from /Users/brijesh/.rvm/gems/ruby-2.2.1/gems/ffi-inline-0.0.4.3/lib/ffi/inline/builders.rb:90:in `block in build'
from /Users/brijesh/.rvm/gems/ruby-2.2.1/gems/ffi-inline-0.0.4.3/lib/ffi/inline/builders.rb:87:in `instance_eval'
from /Users/brijesh/.rvm/gems/ruby-2.2.1/gems/ffi-inline-0.0.4.3/lib/ffi/inline/builders.rb:87:in `build'
from /Users/brijesh/.rvm/gems/ruby-2.2.1/gems/ffi-inline-0.0.4.3/lib/ffi/inline/inline.rb:54:in `singleton_inline'
from /Users/brijesh/.rvm/gems/ruby-2.2.1/gems/ffi-inline-0.0.4.3/lib/ffi/inline/inline.rb:39:in `inline'
from /Users/brijesh/.rvm/gems/ruby-2.2.1/gems/tesseract-ocr-0.1.8/lib/tesseract/c.rb:34:in `<module:C>'
from /Users/brijesh/.rvm/gems/ruby-2.2.1/gems/tesseract-ocr-0.1.8/lib/tesseract/c.rb:31:in `<module:Tesseract>'
from /Users/brijesh/.rvm/gems/ruby-2.2.1/gems/tesseract-ocr-0.1.8/lib/tesseract/c.rb:29:in `<top (required)>'
from /Users/brijesh/.rvm/gems/ruby-2.2.1/gems/tesseract-ocr-0.1.8/lib/tesseract/api.rb:26:in `require'
from /Users/brijesh/.rvm/gems/ruby-2.2.1/gems/tesseract-ocr-0.1.8/lib/tesseract/api.rb:26:in `<top (required)>'
from /Users/brijesh/.rvm/gems/ruby-2.2.1/gems/tesseract-ocr-0.1.8/lib/tesseract-ocr.rb:35:in `require'
from /Users/brijesh/.rvm/gems/ruby-2.2.1/gems/tesseract-ocr-0.1.8/lib/tesseract-ocr.rb:35:in `<top (required)>'
from /Users/brijesh/.rvm/gems/ruby-2.2.1/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `require'
from /Users/brijesh/.rvm/gems/ruby-2.2.1/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /Users/brijesh/.rvm/gems/ruby-2.2.1/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `each'
from /Users/brijesh/.rvm/gems/ruby-2.2.1/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `block in require'
from /Users/brijesh/.rvm/gems/ruby-2.2.1/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `each'
from /Users/brijesh/.rvm/gems/ruby-2.2.1/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `require'
from /Users/brijesh/.rvm/gems/ruby-2.2.1/gems/bundler-1.10.6/lib/bundler.rb:134:in `require'
from /Users/brijesh/Desktop/project/nepal-receipt-processing-2/config/application.rb:15:in `<top (required)>'
from /Users/brijesh/.rvm/gems/ruby-2.2.1/gems/railties-4.1.4/lib/rails/commands/commands_tasks.rb:79:in `require'
from /Users/brijesh/.rvm/gems/ruby-2.2.1/gems/railties-4.1.4/lib/rails/commands/commands_tasks.rb:79:in `block in server'
from /Users/brijesh/.rvm/gems/ruby-2.2.1/gems/railties-4.1.4/lib/rails/commands/commands_tasks.rb:76:in `tap'
from /Users/brijesh/.rvm/gems/ruby-2.2.1/gems/railties-4.1.4/lib/rails/commands/commands_tasks.rb:76:in `server'
from /Users/brijesh/.rvm/gems/ruby-2.2.1/gems/railties-4.1.4/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
from /Users/brijesh/.rvm/gems/ruby-2.2.1/gems/railties-4.1.4/lib/rails/commands.rb:17:in `<top (required)>'
from /Users/brijesh/.rvm/gems/ruby-2.2.1/gems/railties-4.1.4/lib/rails/app_rails_loader.rb:43:in `require'
from /Users/brijesh/.rvm/gems/ruby-2.2.1/gems/railties-4.1.4/lib/rails/app_rails_loader.rb:43:in `block in exec_app_rails'
from /Users/brijesh/.rvm/gems/ruby-2.2.1/gems/railties-4.1.4/lib/rails/app_rails_loader.rb:32:in `loop'
from /Users/brijesh/.rvm/gems/ruby-2.2.1/gems/railties-4.1.4/lib/rails/app_rails_loader.rb:32:in `exec_app_rails'
from /Users/brijesh/.rvm/gems/ruby-2.2.1/gems/railties-4.1.4/lib/rails/cli.rb:5:in `<top (required)>'
from /Users/brijesh/.rvm/gems/ruby-2.2.1/gems/railties-4.1.4/bin/rails:9:in `require'
from /Users/brijesh/.rvm/gems/ruby-2.2.1/gems/railties-4.1.4/bin/rails:9:in `<top (required)>'
from /Users/brijesh/.rvm/gems/ruby-2.2.1/bin/rails:23:in `load'
from /Users/brijesh/.rvm/gems/ruby-2.2.1/bin/rails:23:in `<main>'
from /Users/brijesh/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `eval'
from /Users/brijesh/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `<main>'


I have searched a lot in the internet but could not find the solution. I would really appreciate the help.

Answer

Actually the problem was the installation of the tesseract on mac which installed the current version in which tesseract-ocr gem already lost compatibility with.

The solution in this answer shows how to install an older version of tesseract that is compatible with the current (as of May 2016) tesseract-ocr 0.1.8 gem

brew install https://raw.githubusercontent.com/Homebrew/homebrew/8ba134eda537d2cee7daa7ebdd9f728389d9c53e/Library/Formula/tesseract.rb 
Comments