When I run:
$ heroku run bundle exec rake environment elasticsearch:import:model CLASS='Artist' FORCE=true
the response in the terminal is:
Running bundle exec rake environment elasticsearch:import:model CLASS=Artist FORCE=true on doremi... up, run.3015
Starting up a new ElasticSearch client with https://hexcode.bonsai.io
rake aborted!
NameError: uninitialized constant Elasticsearch
/app/vendor/bundle/ruby/2.0.0/gems/bonsai-elasticsearch-rails-0.0.4/lib/bonsai/elasticsearch/rails.rb:4:in `<top (required)>'
/app/vendor/bundle/ruby/2.0.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:85:in `require'
/app/vendor/bundle/ruby/2.0.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:85:in `rescue in block in require'
/app/vendor/bundle/ruby/2.0.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:68:in `block in require'
/app/vendor/bundle/ruby/2.0.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:61:in `each'
/app/vendor/bundle/ruby/2.0.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:61:in `require'
/app/vendor/bundle/ruby/2.0.0/gems/bundler-1.9.7/lib/bundler.rb:134:in `require'
/app/config/application.rb:16:in `<top (required)>'
/app/Rakefile:4:in `require'
/app/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
The error appears to originate from this require statement in lib/tasks/elasticsearch.rake
require 'elasticsearch/rails/tasks/import'
I have checked that all my elastic-*
gems are their most up to date versions: 0.1.7 for elasticsearch-rails and elasticsearch-model, 0.0.4 for bonsai-elasticsearch-rails, however I did notice here https://rubygems.org/gems/bonsai-elasticsearch-rails that bonsai-elastic-search rails depends on bundler 1.5 and Heroku is using 1.9.7 which is not possible to change as far as I can see. Could this be the crux of the matter?
I also have a similar error in my logs when I try to deploy
Oct 09 17:04:27 doremi app/worker.1: NameError: uninitialized constant Elasticsearch
Oct 09 17:04:27 doremi app/worker.1: rake aborted!
Oct 09 17:04:27 doremi app/worker.1: /app/vendor/bundle/ruby/2.2.0/gems/bonsai-elasticsearch-rails-0.0.4/lib/bonsai/elasticsearch/rails.rb:4:in `<top (required)>'
Oct 09 17:04:27 doremi app/worker.1: /app/vendor/bundle/ruby/2.2.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:85:in `require'
Oct 09 17:04:27 doremi app/worker.1: /app/vendor/bundle/ruby/2.2.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:85:in `rescue in block in require'
Oct 09 17:04:27 doremi app/worker.1: /app/vendor/bundle/ruby/2.2.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:68:in `block in require'
Oct 09 17:04:27 doremi app/worker.1: /app/vendor/bundle/ruby/2.2.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:61:in `each'
Oct 09 17:04:27 doremi app/worker.1: /app/vendor/bundle/ruby/2.2.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:61:in `require'
Oct 09 17:04:27 doremi app/worker.1: /app/vendor/bundle/ruby/2.2.0/gems/bundler-1.9.7/lib/bundler.rb:134:in `require'
Oct 09 17:04:27 doremi app/worker.1: /app/config/application.rb:16:in `<top (required)>'
Oct 09 17:04:27 doremi app/worker.1: /app/Rakefile:4:in `require'
Oct 09 17:04:27 doremi app/worker.1: /app/Rakefile:4:in `<top (required)>'
Oct 09 17:04:27 doremi app/worker.1: LoadError: cannot load such file -- bonsai-elasticsearch-rails
Oct 09 17:04:27 doremi app/worker.1: /app/vendor/bundle/ruby/2.2.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:76:in `require'
Oct 09 17:04:27 doremi app/worker.1: /app/vendor/bundle/ruby/2.2.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
Oct 09 17:04:27 doremi app/worker.1: /app/vendor/bundle/ruby/2.2.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:72:in `each'
Oct 09 17:04:27 doremi app/worker.1: /app/vendor/bundle/ruby/2.2.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:72:in `block in require'
Oct 09 17:04:27 doremi app/worker.1: /app/vendor/bundle/ruby/2.2.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:61:in `each'
Oct 09 17:04:27 doremi app/worker.1: /app/vendor/bundle/ruby/2.2.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:61:in `require'
Oct 09 17:04:27 doremi app/worker.1: /app/vendor/bundle/ruby/2.2.0/gems/bundler-1.9.7/lib/bundler.rb:134:in `require'
Oct 09 17:04:27 doremi app/worker.1: /app/config/application.rb:16:in `<top (required)>'
Oct 09 17:04:27 doremi app/worker.1: /app/Rakefile:4:in `require'
Oct 09 17:04:27 doremi app/worker.1: /app/Rakefile:4:in `<top (required)>'
rails/bundler requires the gems in the order they’re declared in the gemfile. This error occurred because I was declaring bonsai-elasticsearch-rails
above elasticsearch-rails
and elasticsearch-model
. It was therefore resolved by declaring bonsai-elasticsearch-rails
underneath the other two.