4

Im using the gem for thinking sphinx:

sudo gem install freelancing-god-thinking-sphinx \
  --source http://gems.github.com

So:

require 'vendor/plugins/thinking-sphinx/recipes/thinking_sphinx'

Which is prescribed on the website does not work.

How do I include the capistrano thinking sphinx tasks in my deploy.rb file when using the gem?

EDIT

Adding: require 'thinking_sphinx/deploy/capistrano'

gives me:

 
/usr/lib/ruby/gems/1.8/gems/freelancing-god-thinking-sphinx-1.1.12/lib/thinking_sphinx/deploy/capistrano.rb:1: undefined method `namespace' for main:Object (NoMethodError)
        from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
        from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
        from /usr/lib/ruby/gems/1.8/gems/capistrano-2.5.8/lib/capistrano/configuration/loading.rb:152:in `require'

Sam Saffron
  • 128,308
  • 78
  • 326
  • 506

4 Answers4

5

The simple require as defined in another answer - thinking_sphinx/deploy/capistrano - should work. If it's not, are you seeing any errors? What version of the gem are you using?

If that fails, perhaps try a sudo gem update in case your gems are old.

Sam Saffron
  • 128,308
  • 78
  • 326
  • 506
pat
  • 16,116
  • 5
  • 40
  • 46
  • Pat, thanks so much for taking your time to answer, Im still getting an error (using cap 2.5.8 and sphinx 1.1.12) I put a full log in my answer – Sam Saffron Sep 22 '09 at 09:09
  • OK, *sudo gem update* fixed whatever mess I had. Thanks for your help and for the awesome library. (I hope you don't mind that I edited that in to your answer) – Sam Saffron Sep 22 '09 at 09:21
  • Not at all, as long as you got it working :) I don't think the cap tasks were there in 1.1.12 (could be, it's been a few months), so that was almost certainly the cause. – pat Sep 23 '09 at 13:32
3

@Khelll: could you please read the Topic? You are pasting code for using TS as plugin.

As Gem you should use:

require 'thinking_sphinx/deploy/capistrano'

That works perfectly.

One should also change the capistrano tasks mentioned on the website to reflect the new before and after callbacks from capistrano to get rid off the deprecation notices:

before "deploy:update_code", "thinking_sphinx:stop"
after "deploy:symlink", "symlink_sphinx_indexes"
after "deploy:symlink", "thinking_sphinx:configure"
after "deploy:symlink", "thinking_sphinx:start"
carpeliam
  • 6,691
  • 2
  • 38
  • 42
tvdeyen
  • 723
  • 4
  • 9
  • this is exactly what I was looking for, with one exception: I needed to change the last 3 lines (after 'deploy:update_code') to `after "deploy:symlink"`. Otherwise, current_path still refers to the old directory. – carpeliam Apr 26 '11 at 06:04
1

You're talking about installing a gem and then requiring a plugin. Have you tried installing the plugin version of Thinking Sphinx?

EDIT: I speak too quickly, clearly. The deployment recipes are in lib/thinking_sphinx/deploy/capistrano. Try require 'thinking_sphinx/deploy/capistrano' and you should have access to the deployment recipes—in a test project I just threw that in my Rakefile and I have access to them.

On a brand new project, I put the following in my Capfile:

load 'deploy' if respond_to?(:namespace) # cap2 differentiator
Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
load 'config/deploy'
require 'thinking_sphinx/deploy/capistrano'

When I do cap -T, I see the thinking_sphinx capistrano tasks. I think what I wrote above was because I had the plugin installed. /me smacks self.

theIV
  • 25,434
  • 5
  • 54
  • 58
0

How about:

require 'vendor/plugins/thinking_sphinx/lib/thinking_sphinx/deploy/capistrano'
khelll
  • 23,590
  • 15
  • 91
  • 109