【问题标题】:Rails sunspot error on sunspot:solr:start太阳黑子上的Rails太阳黑子错误:solr:start
【发布时间】:2013-07-24 01:38:43
【问题描述】:

我实际上是在尝试为 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。是否有人已经面临同样的问题或知道解决方法?

非常感谢您的帮助

【问题讨论】:

    标签: ruby-on-rails config sunspot


    【解决方案1】:

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

    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
    

    【讨论】:

    • 非常感谢,你让我开心:)
    【解决方案2】:

    您可能想尝试更新您的 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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多