Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't start Solr with rake task #4

Open
cimm opened this issue Feb 9, 2010 · 7 comments
Open

Can't start Solr with rake task #4

cimm opened this issue Feb 9, 2010 · 7 comments

Comments

@cimm
Copy link

cimm commented Feb 9, 2010

I installed acts_as_solr_reloaded as a gem and added the require statement in a rake task as specified in this older documentation I found via Google. I can run the rake task but Solr doesn't want to start as the rake task is looking for a directory that doesn't exist:

$ rake solr:start
(in /Users/Projects/myproject)
rake aborted!
No such file or directory - /Library/Ruby/Gems/1.8/gems/acts_as_solr_reloaded-1.3.0/solr

I checked the directory and the /solr one should be /lib/solr if I'm not mistaken.

@dcrec1
Copy link
Owner

dcrec1 commented Feb 9, 2010

Hi Simon,

Solr server it not included in the gem anymore. If you need it, you can clone this project:

http://github.com/dcrec1/jetty-solr

It's configured to support all features in acts_as_sor_reloaded.

@cimm
Copy link
Author

cimm commented Feb 9, 2010

Hi Diego,

I cloned your Jetty repository and started the Jetty server but I can't connect to the server from my Rails app. Both are running on the same machine and I can access the Solr webinterface but the Rails app keeps complaining:

Couldn't connect to the Solr server at http://localhost:8982/solr. You have a nil object when you didn't expect it!

I don't need the config file when I want to use the defaults, do I? Do I need to run the Jetty server as root (tried but it didn't help)? The port seems correct...

@dcrec1
Copy link
Owner

dcrec1 commented Feb 9, 2010

Hi Simon, can you plase copy the full stack trace?

About the config file, are you referring to config/solr.yml ? If yes, you need it but it seems you have it already.

@romul
Copy link
Contributor

romul commented Feb 9, 2010

I start solr via such command:

rake solr:start SOLR_PATH="/home/roman/www/jetty-solr"

and in lib/tasks/acts_as_solr.rake

SOLR_PATH = ENV['SOLR_PATH']
require "acts_as_solr/tasks"

it works good.

@cimm
Copy link
Author

cimm commented Feb 10, 2010

With the config/solr.yml file in place I get the following error while saving a new record:

Couldn't connect to the Solr server at . You have a nil object when you didn't expect it!

Without the config file it seems to find address (but not the server), oddly enough:

Couldn't connect to the Solr server at http://localhost:8982/solr. You have a nil object when you didn't expect it!

I tried the same with the acts_as_solr plugin and that one works, even with your Jetty server. The problem only occurs with the acts_as_solr_reloaded plugin (or gem).

Here is the stack trace:

Couldn't connect to the Solr server at http://localhost:8982/solr. You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[]
/Users/Projects/myproject/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr.rb:61:in `execute'
/Users/Projects/myproject/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/common_methods.rb:55:in `solr_add'
/Users/Projects/myproject/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/instance_methods.rb:15:in `solr_save'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:178:in `send'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:178:in `evaluate_method'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:166:in `call'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:93:in `run'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:92:in `each'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:92:in `send'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:92:in `run'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:276:in `run_callbacks'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/callbacks.rb:344:in `callback'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/callbacks.rb:251:in `create_or_update'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:2555:in `save_without_validation!'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/validations.rb:1088:in `save_without_dirty!'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/dirty.rb:87:in `save_without_transactions!'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:200:in `save!'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in `transaction'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:182:in `transaction'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:200:in `save!'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:208:in `rollback_active_record_state!'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:200:in `save!'
/Users/Projects/myproject/lib/tasks/db_development.rake:30
/Users/Projects/myproject/lib/tasks/db_development.rake:19:in `each'
/Users/Projects/myproject/lib/tasks/db_development.rake:19
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19

@dcrec1
Copy link
Owner

dcrec1 commented Feb 10, 2010

It seems that for a reason ENV['RAILS_ENV'] is nil and that is causing the error.

You are executing a rake task right? Plz try to set ENV['RAILS_ENV'] in your task or ensure that itsn't nil and try again.

If this didn't resolve the problem, plz try to debug Post.execute at acts_as_solr.rb, line 47. I think the plugin is breaking at line 49 when you have the config file and at line 57 when not, exactly the first time when used ENV['RAILS_ENV'] in both cases.

@jclemans
Copy link

I am also running into this issue.

solr_environment.rb has SOLR_PATH = File.expand_path("#{dir}/../solr") but the solr directory is actually located at ("#{dir}/../lib/solr") (in the lib folder). Because this is wrong SOLR_PATH is nil every time you try to rake solr:start.

Did the config path get changed or was the solr folder moved down into lib at some point?
EDIT - I see there was a change to the way the PATH is handled on this commit:
fb6b94c
You will probably only run into this issue if you're running an older version of this gem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants