pat / thinking-sphinx

Sphinx/Manticore plugin for ActiveRecord/Rails
http://freelancing-gods.com/thinking-sphinx
MIT License
1.63k stars 468 forks source link

No such file to load in Rails 3.1 Engines #278

Closed akremer closed 13 years ago

akremer commented 13 years ago

Hi Pat,

This is semi-related to #230 -- I've created a Rails 3.1rc6 engine named "product" like so:

rails plugin new product --mountable -d mysql

I then created my indexable models, and added thinking_sphinx as a dependency in the engine's gemspec:

s.add_dependency "thinking-sphinx", ">= 2.0.6"

In the engine's lib/product/engine.rb, I followed #230 and ensured that any app which uses this engine adds the engine's model directory:

require 'thinking_sphinx'

module Product
  class Engine < Rails::Engine
    config.after_initialize do
      ::ThinkingSphinx::Configuration.instance.model_directories << File.expand_path('../../../app/models/', __FILE__)
    end
  end
end

The problem is that whenever I try to run any rails command inside the engine's folder (IE, to generate new models or even a migration), I get the following:

/Users/akremer/proj/product/lib/product/engine.rb:1:in `require': no such file to load -- thinking_sphinx (LoadError)
from /Users/akremer/proj/product/lib/product/engine.rb:1:in `<top (required)>'
from /Users/akremer/proj/product/lib/product.rb:1:in `require'
from /Users/akremer/proj/product/lib/product.rb:1:in `<top (required)>'
from /Users/akremer/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.15/lib/bundler/runtime.rb:68:in `require'
from /Users/akremer/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.15/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /Users/akremer/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.15/lib/bundler/runtime.rb:66:in `each'
from /Users/akremer/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.15/lib/bundler/runtime.rb:66:in `block in require'
from /Users/akremer/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.15/lib/bundler/runtime.rb:55:in `each'
from /Users/akremer/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.15/lib/bundler/runtime.rb:55:in `require'
from /Users/akremer/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.15/lib/bundler.rb:120:in `require'
from /Users/akremer/proj/product/test/dummy/config/application.rb:5:in `<top (required)>'
from /Users/akremer/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.0.rc6/lib/rails/commands.rb:21:in `require'
from /Users/akremer/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.0.rc6/lib/rails/commands.rb:21:in `<top (required)>'
from /Users/akremer/proj/product/test/dummy/script/rails:6:in `require'
from /Users/akremer/proj/product/test/dummy/script/rails:6:in `<top (required)>'
from script/rails:6:in `load'
from script/rails:6:in `<main>'

It seems like the dummy application rails creates is trying to use the engine, but not finding Thinking Sphinx even though it is listed as a dependency in the gemspec. If I run a bundle in the dummy app's folder I can see TS is being used so I don't think it's an issue with the dependency itself.

Any ideas?

Thanks for your help!

pat commented 13 years ago

So it turns out the 2.0.6 gem was pretty much empty - I'd made a presumption on git syntax, which is now fixed, and 2.0.7 is released. Give that a shot, let me know if it fixes the problem :)

akremer commented 13 years ago

Argh! That wasn't something I had even thought of checking. That's working great now.. Thanks!

pat commented 13 years ago

I'd be surprised if anyone had thought to check it - I'm glad @pixeltrix pointed it out to me, otherwise I would have been confused as well.

akremer commented 13 years ago

No worries -- learned more about the loading procedures of engines than I wouldve ever cared for these past few hours... A good experience :-) ------Original Message------ From: freelancing-god To: Alex Kremer Subject: Re: [thinking-sphinx] No such file to load in Rails 3.1 Engines (#278) Sent: Aug 29, 2011 00:23

I'd be surprised if anyone had thought to check it - I'm glad @pixeltrix pointed it out to me, otherwise I would have been confused as well.

Reply to this email directly or view it on GitHub: https://github.com/freelancing-god/thinking-sphinx/issues/278#issuecomment-1925902