2013-07-24 99 views
0

我實際上正在嘗試安裝和使用Rails黑子寶石(https://github.com/sunspot/sunspot)。到目前爲止,這是我所做的。我加的依賴在我Gemfile太陽黑子上的Rails太陽黑子錯誤:solr:start

gem 'sunspot_rails' 
gem 'sunspot_solr' 

然後我也跑bundle,並使用rails generate sunspot_rails:install配置文件。到現在爲止還挺好。

但是,當我試圖運行bundle exec rake sunspot:solr:start,我面臨着以下錯誤:

rake aborted! 
Don't know how to build task 'sunspot:solr:start' 
/Users/project/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/task_manager.rb:49:in `[]' 
/Users/project/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:148:in `invoke_task' 
/Users/project/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:106:in `block (2 levels) in top_level' 
/Users/project/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:106:in `each' 
/Users/project/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:106:in `block in top_level' 
/Users/project/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:115:in `run_with_threads' 
/Users/project/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:100:in `top_level' 
/Users/project/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:78:in `block in run' 
/Users/project/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling' 
/Users/project/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:75:in `run' 
/Users/project/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.1.0/bin/rake:33:in `<top (required)>' 
/Users/project/.rbenv/versions/2.0.0-p247/bin/rake:23:in `load' 
/Users/project/.rbenv/versions/2.0.0-p247/bin/rake:23:in `<main>' 
我實際使用Rails 4和Ruby 2.0.0

。有沒有人已經面臨同樣的問題或知道一種方法來解決這個問題?

非常感謝您的幫助

回答

7

我有同樣的錯誤,我是能夠通過將以下文件來解決。

Source of Rakefile Duplicate Question

lib/tasks/solr.rake 

namespace :sunspot do 
    namespace :solr do 
    desc 'Start the Solr instance' 
    task :start => :environment do 
     case RUBY_PLATFORM 
     when /w(in)?32$/, /java$/ 
      abort("This command is not supported on #{RUBY_PLATFORM}. " + 
      "Use rake sunspot:solr:run to run Solr in the foreground.") 
    end 

    if defined?(Sunspot::Rails::Server) 
    Sunspot::Rails::Server.new.start 
    else 
    Sunspot::Solr::Server.new.start 
    end 
    puts "Successfully started Solr ..." 
end 

desc 'Run the Solr instance in the foreground' 
task :run => :environment do 
    if defined?(Sunspot::Rails::Server) 
    Sunspot::Rails::Server.new.run 
    else 
    Sunspot::Solr::Server.new.run 
    end 
end 

desc 'Stop the Solr instance' 
task :stop => :environment do 
    case RUBY_PLATFORM 
    when /w(in)?32$/, /java$/ 
    abort("This command is not supported on #{RUBY_PLATFORM}. " + 
      "Use rake sunspot:solr:run to run Solr in the foreground.") 
    end 

    if defined?(Sunspot::Rails::Server) 
    Sunspot::Rails::Server.new.stop 
    else 
    Sunspot::Solr::Server.new.stop 
    end 
    puts "Successfully stopped Solr ..." 
end 

# for backwards compatibility 
task :reindex => :"sunspot:reindex" 
end 
end 
+0

非常感謝,你讓我很快樂:) – lkartono

+0

真棒奏效。 – Sarvesh

+0

甜!謝謝!!這很好。 – DavidVII

0

你可能想嘗試更新的sunspot_solr寶石的版本,如果RubyGems是給你錯誤sunspot_solr的舊版本。

嘗試添加以下內容到Gemfile中,而不是gem 'sunspot_solr'和運行bundle install + bundle exec rake sunspot:solr:start

gem 'sunspot_solr', '~> 2.0.0', group: :development