gpt4 book ai didi

ruby-on-rails - rake 太阳黑子 :solr:start throwing an error

转载 作者:行者123 更新时间:2023-12-02 18:01:59 28 4
gpt4 key购买 nike

我正在尝试将 sunspot 与 Rails 4 一起使用,但遇到了一些问题。当我的 gemfile 中只有 gem 'sunspot_rails', '2.0.0' 时,我收到此错误:

Note: This task has been moved to the sunspot_solr gem. To install, start and
stop a local Solr instance, please add sunspot_solr to your Gemfile:
group :development do
gem 'sunspot_solr'
end

但是当我添加该 gem(也是 v 2.0.0)时,我收到此错误:

rake aborted!
Don't know how to build task 'sunspot:solr:start'
/home/toasty/.rvm/gems/ruby-2.0.0-p195/bin/ruby_noexec_wrapper:14:in `eval'
/home/toasty/.rvm/gems/ruby-2.0.0-p195/bin/ruby_noexec_wrapper:14:in `<main>'
(See full trace by running task with --trace)

我看到过这个问题: Sunspot/Solr raketasks not loading in Rails 3 Mountable Engine但它似乎不适用于我的情况。有人有什么想法吗? sunspot_solr 与 Rails 4 不兼容吗?

最佳答案

我也遇到了同样的问题。我不记得了,但我发现你需要添加这个 rake 任务

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

编辑~ Source of Rakefile

关于ruby-on-rails - rake 太阳黑子 :solr:start throwing an error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17647963/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com