Jul 13, 2011

Sunspot Solr startup problem on Windows

There is an error on Windows because command-line arguments are escaped in a wrong way.

This fix works for me:http://www.trdev.co.uk/2011/07/03/sunspot-and-solr-search-on-windows-7-errors/

Basically, we just go to sunspot gems in Ruby and change this file:

sunspot/lib/sunspot/server.rb

and do this patch

command << "-Xms#{min_memory}" if min_memory

command << "-Xmx#{max_memory}" if max_memory

command << "-Djetty.port=#{port}" if port

- command << "-Dsolr.data.dir=#{solr_data_dir}" if solr_data_dir

- command << "-Dsolr.solr.home=#{solr_home}" if solr_home

- command << "-Djava.util.logging.config.file=#{logging_config_path}" if logging_config_path

+ command << "-Dsolr.data.dir=\"#{solr_data_dir}\"" if solr_data_dir

+ command << "-Dsolr.solr.home=\"#{solr_home}\"" if solr_home

+ command << "-Djava.util.logging.config.file=\"#{logging_config_path}\"" if logging_config_path

command << '-jar' << File.basename(solr_jar)

FileUtils.cd(File.dirname(solr_jar)) do

- exec(Escape.shell_command(command))

+ exec(command.join(" "))

end

end