local_options error on linux but not on osx

8 views
Skip to first unread message

fch...@researchedgellc.com

unread,
Dec 17, 2009, 12:32:10 AM12/17/09
to Thinking Sphinx
Hi All:

So I'm running rails 2.1.2, ruby 1.8.7 (2008-08-11 patchlevel 72), and
thinking-sphinx as gem 1.3.13 on both ubuntu 8.10 (production) and osx
leopard (development).

thinking-sphinx runs fine on osx, but any search on ubuntu generates a
stack trace like this:
------------
Sphinx Querying: 'hst @status PUBLISHED'


NoMethodError (undefined method `local_options' for nil:NilClass):
/usr/lib/ruby/gems/1.8/gems/thinking-sphinx-1.3.13/lib/
thinking_sphinx/search.rb:346:in `client'
/usr/lib/ruby/gems/1.8/gems/thinking-sphinx-1.3.13/lib/
thinking_sphinx/search.rb:258:in `populate'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/
core_ext/benchmark.rb:8:in `realtime'
/usr/lib/ruby/gems/1.8/gems/thinking-sphinx-1.3.13/lib/
thinking_sphinx/search.rb:257:in `populate'
/usr/lib/ruby/gems/1.8/gems/thinking-sphinx-1.3.13/lib/
thinking_sphinx/search.rb:380:in `call'
/usr/lib/ruby/gems/1.8/gems/thinking-sphinx-1.3.13/lib/
thinking_sphinx/search.rb:380:in `retry_on_stale_index'
/usr/lib/ruby/gems/1.8/gems/thinking-sphinx-1.3.13/lib/
thinking_sphinx/search.rb:254:in `populate'
/usr/lib/ruby/gems/1.8/gems/thinking-sphinx-1.3.13/lib/
thinking_sphinx/search.rb:186:in `total_entries'
/app/controllers/comments_controller.rb:131:in `search'
----------
Googling around it seems that a similar problem was addressed for
local_options in
http://groups.google.com/group/thinking-sphinx/browse_thread/thread/c1e550f332c08dbe/e60408dea0acccd2?lnk=raot

Any ideas?

Thanks

Forrest

fch...@researchedgellc.com

unread,
Dec 17, 2009, 2:41:06 PM12/17/09
to Thinking Sphinx
I backed this off to 1.3.12 and I don't get that error on ubuntu. At
least on my staging sever.

Forrest

peter

unread,
Dec 19, 2009, 12:12:47 AM12/19/09
to Thinking Sphinx
On Dec 16, 9:32 pm, "fkchang2...@gmail.com"

<fch...@researchedgellc.com> wrote:
> Hi All:
>
> So I'm running rails 2.1.2, ruby 1.8.7 (2008-08-11 patchlevel 72), and
> thinking-sphinx as gem 1.3.13 on both ubuntu 8.10 (production) and osx
> leopard (development).
>
> thinking-sphinx runs fine on osx, but any search on ubuntu generates a
> stack trace like this:

Hey. I've got the same problem. I'm running ubuntu linux (8.04), rails
2.3.5, thinking_sphinx 1.3.13.

I discovered that this 'local-options' problem arises when my app in
run in the browser, but NOT under console. My controller method is the
following:

def search
@posts = Post.search params[:q], :page => params[:page]
# hack! hack! hack! thinking_sphinx does not include virtual
attributes in results
@posts.each do |post|
...
end
render
end

Running the app via the browser, and executing that controller action,
makes rails barf at the line: "@posts.each do |post|". Here is the
trace:

/home/peter/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/
whiny_nil.rb:52:in `method_missing'


/usr/lib/ruby/gems/1.8/gems/thinking-sphinx-1.3.13/lib/thinking_sphinx/
search.rb:346:in `client'
/usr/lib/ruby/gems/1.8/gems/thinking-sphinx-1.3.13/lib/thinking_sphinx/
search.rb:258:in `populate'

/home/peter/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/
core_ext/benchmark.rb:10:in `realtime'


/usr/lib/ruby/gems/1.8/gems/thinking-sphinx-1.3.13/lib/thinking_sphinx/
search.rb:257:in `populate'
/usr/lib/ruby/gems/1.8/gems/thinking-sphinx-1.3.13/lib/thinking_sphinx/
search.rb:380:in `call'
/usr/lib/ruby/gems/1.8/gems/thinking-sphinx-1.3.13/lib/thinking_sphinx/
search.rb:380:in `retry_on_stale_index'
/usr/lib/ruby/gems/1.8/gems/thinking-sphinx-1.3.13/lib/thinking_sphinx/
search.rb:254:in `populate'
/usr/lib/ruby/gems/1.8/gems/thinking-sphinx-1.3.13/lib/thinking_sphinx/

search.rb:209:in `each_with_group_and_count'
/home/peter/apps/ysc/config/initializers/savage_beast_extensions.rb:
8:in `search'

That last line of the trace -- /home/peter/apps/ysc/config/
initializers/savage_beast_extensions.rb:8:in `search' -- refers to the
"@posts.each do |post|" line in the "search" method above.

Now, I can run this same controller action from within console as
follows:

>> app.get '/posts/search?q=cancer'
=> 200
>> app.response.body
=> "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> ...
etc ... etc

In console, there's no problem at all with this action. The action
renders a proper set of search results. No exception is raised.

So this seems to be a bug in TS having to do with:

1. linux vs. osx
2. the difference between running code in a browser vs. running the
same code under console

Weird.

peter

unread,
Dec 19, 2009, 12:24:14 AM12/19/09
to Thinking Sphinx
I just tried the same thing -- i.e. backing off to 1.3.12. Rebuilt the
index. No change for me though. Still get the same strange bug I
described.

On Dec 17, 11:41 am, "fkchang2...@gmail.com"

fch...@researchedgellc.com

unread,
Dec 19, 2009, 2:35:24 AM12/19/09
to Thinking Sphinx

On Dec 18, 9:24 pm, peter <psav...@gmail.com> wrote:
> I just tried the same thing -- i.e. backing off to 1.3.12. Rebuilt the
> index. No change for me though. Still get the same strange bug I
> described.
>

Actually, my latest deploy to 1.3.12 on ubuntu is having the
local_options problem again. I backed down now to 1.3.11 and it's
working for this deployment. I hope this doesn't become a pattern.

Pat Allan

unread,
Dec 19, 2009, 2:42:43 AM12/19/09
to thinkin...@googlegroups.com
I've had someone create an issue on GitHub listing how I can reproduce the issue - I'll try to spend some time on this tonight, see if I can determine the cause and figure out a fix.

--
Pat

> --
>
> You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.
> To post to this group, send email to thinkin...@googlegroups.com.
> To unsubscribe from this group, send email to thinking-sphi...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/thinking-sphinx?hl=en.
>
>

fch...@researchedgellc.com

unread,
Dec 19, 2009, 8:51:15 PM12/19/09
to Thinking Sphinx
Hi Pat:

Thanks for the attention. It seems my fix is intermittent, sometimes
it works, sometimes I get the local options

On Dec 18, 11:42 pm, Pat Allan <p...@freelancing-gods.com> wrote:
> I've had someone create an issue on GitHub listing how I can reproduce the issue - I'll try to spend some time on this tonight, see if I can determine the cause and figure out a fix.
>
> --
> Pat
>

peter

unread,
Dec 19, 2009, 10:16:24 PM12/19/09
to Thinking Sphinx
Thanks Pat. Hope we can get to bottom of this one.

On Dec 18, 11:42 pm, Pat Allan <p...@freelancing-gods.com> wrote:

Pat Allan

unread,
Dec 20, 2009, 7:38:29 AM12/20/09
to thinkin...@googlegroups.com
Just a quick update - the reproduction steps I was given last night was to do with running TS via Merb. Same bug, but as far as I can tell, not quite the same cause.

I'm currently trying to reproduce the issue with Rails 2.1.2, but no luck as yet... whether it be in production or development (and I'm quite certain that's the reason for the bug on ubuntu for Forrest - it's a production environment issue, and most likely related to cached_classes being set to true).

If anyone can reproduce it on any version of Rails locally, I'd love to know how you did it - a test app or instructions would be fantastic. I'll spend some more time tomorrow night looking into it.

--
Pat

Pat Allan

unread,
Dec 21, 2009, 6:16:58 PM12/21/09
to thinkin...@googlegroups.com
Okay, I've removed a method that may be causing this problem - I'm not entirely sure though, because I've not been able to reproduce it. Still, if you could give 1.3.14 a spin, see if that helps matters, that'd be great.

Cheers

--
Pat

fch...@researchedgellc.com

unread,
Dec 21, 2009, 8:39:42 PM12/21/09
to Thinking Sphinx
Hi Pat:

So, I run 2 apps of the staging box, and they seem to be consistently
running w/o a problem right now on Ubuntu. I'll be deploying several
times this week, so I'll update you if something goes south.

Thanks so much for the speedy turnaround.

Merry Holidays if I don't feedback before then.

Forrest

On Dec 21, 3:16 pm, Pat Allan <p...@freelancing-gods.com> wrote:
> Okay, I've removed a method that may be causing this problem - I'm not entirely sure though, because I've not been able to reproduce it. Still, if you could give 1.3.14 a spin, see if that helps matters, that'd be great.
>
> Cheers
>
> --
> Pat
>
> On 20/12/2009, at 11:38 PM, Pat Allan wrote:
>
>
>
> > Just a quick update - the reproduction steps I was given last night was to do with running TS via Merb. Same bug, but as far as I can tell, not quite the same cause.
>
> > I'm currently trying to reproduce the issue with Rails 2.1.2, but no luck as yet... whether it be in production or development (and I'm quite certain that's the reason for the bug on ubuntu for Forrest - it's a production environment issue, and most likely related to cached_classes being set to true).
>
> > If anyone can reproduce it on any version of Rails locally, I'd love to know how you did it - a test app or instructions would be fantastic. I'll spend some more time tomorrow night looking into it.
>
> > --
> > Pat
>
> > On 20/12/2009, at 2:16 PM, peter wrote:
>
> >> Thanks Pat. Hope we can get to bottom of this one.
>
> >> On Dec 18, 11:42 pm, Pat Allan <p...@freelancing-gods.com> wrote:
> >>> I've had someone create an issue on GitHub listing how I can reproduce the issue - I'll try to spend some time on this tonight, see if I can determine the cause and figure out a fix.
>
> >>> --
> >>> Pat
>
> >> --
>
> >> You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.
> >> To post to this group, send email to thinkin...@googlegroups.com.
> >> To unsubscribe from this group, send email to thinking-sphi...@googlegroups.com.

> >> For more options, visit this group athttp://groups.google.com/group/thinking-sphinx?hl=en.

peter

unread,
Dec 21, 2009, 11:04:35 PM12/21/09
to Thinking Sphinx
Thanks Pat! Seems to have done the trick for my present purposes. Have
a great holidays.

p.s. Hopefully my skill level can come up enough to debug these things
for myself to provide you more than just a trace dump.

peter

unread,
Dec 22, 2009, 2:04:10 AM12/22/09
to Thinking Sphinx
Looks like I jumped the gun on my report. It seems this change "fixed"
the problem for only the first run of search. That is, running my app
from the browser, searching the Post class generates search results
nicely. But the second time any search is run, a strange exception is
raised:

Processing PostsController#search (for 127.0.0.1 at 2009-12-21
22:42:48) [GET]
Parameters: {"commit"=>"Search", "q"=>"ogbono and body fat"}
Sphinx Querying: 'ogbono and body fat'
Sphinx (0.010020s) Found 8 results
Post Load (0.4ms) SELECT * FROM `posts` WHERE (`posts`.`id` IN
(666,233,662,700,706,718,719,720))
Topic Columns (1.5ms) SHOW FIELDS FROM `topics`

TypeError (can't dup NilClass):
lib/plugin_extensions.rb:25:in `search'
/usr/lib/ruby/gems/1.8/gems/thinking-sphinx-1.3.14/lib/
thinking_sphinx/search.rb:116:in `each'
/usr/lib/ruby/gems/1.8/gems/thinking-sphinx-1.3.14/lib/
thinking_sphinx/search.rb:116:in `send'
/usr/lib/ruby/gems/1.8/gems/thinking-sphinx-1.3.14/lib/
thinking_sphinx/search.rb:116:in `method_missing'
lib/plugin_extensions.rb:24:in `search'


Here is the "search" method mentioned above:

def search
@posts = Post.search params[:q]#, :page => params[:page]


# hack! hack! hack! thinking_sphinx does not include
virtual attributes in results
@posts.each do |post|

post.topic_title =post.topic.title
... etc ...

Line 24 is: @posts.each do |post|
Line 25 is: post.topic_title =post.topic.title

Like I said, firing up ./script/server, the first time through this
method, no problems. But every subsequent time this method is called,
it barfs on Line 25.

Interesting that in version 1.3.13, it was barfing at Line 24 -- i.e.
just on @posts.each being called. Now, with 1.3.14, @posts seems ok
(i.e. I can query it using 'each'), but there seems to be a problem
with the individual post objects, or something related to them.

BTW -- every Post object belongs to a valid Topic object in this db,
so post.topic is never nil in this data set.

Also, as with before, I can't replicate this problem running
Post.search in the console and querying the resulting Post objects. I
can issue as many searches, and query as many of the search results as
I like in console. Nothing blows up. This is just a browser-run app
problem.

Thanks again for the attention on this one. I'll try to dig deeper
into TS tomorrow to figure this one out.

On Dec 21, 5:39 pm, "fkchang2...@gmail.com"

peter

unread,
Dec 22, 2009, 8:50:26 PM12/22/09
to Thinking Sphinx
Don't know what the problem is, but I confirmed that the problem is
not with Thinking Sphinx. So thanks again, Pat, for fixing this one.
Reply all
Reply to author
Forward
0 new messages