0

我实际上正在尝试为 Rails ( https://github.com/sunspot/sunspot ) 安装和使用 Sunspot gem。到目前为止,这就是我所做的。我在我的添加了依赖项Gemfile

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。有没有人已经面临同样的问题或知道解决这个问题的方法?

非常感谢您的帮助

4

2 回答 2

7

通过添加以下文件,我遇到了同样的错误。

Rakefile 重复问题的来源

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
于 2013-07-24T04:48:32.147 回答
0

您可能想尝试更新您的 sunspot_solr gem 版本,以防 Rubygems 错误地为您提供了旧版本的 sunspot_solr。

尝试将其添加到您的 gemfile 中,而不是gem 'sunspot_solr'运行bundle install+ bundle exec rake sunspot:solr:start

gem 'sunspot_solr', '~> 2.0.0', group: :development
于 2013-07-24T03:23:36.900 回答