太阳黑子 solr rake 问题

Sunspot solr rake issue

当我尝试执行 rake 命令时,出现此错误。 我有一个 solr 可以正常运行的应用程序,现在我正在尝试使用 solr 构建一个新应用程序我无法继续

rake sunspot:install --trace

rake aborted!
LoadError: cannot load such file -- active_support/core_ext/object/to_json
/home/vaibhav/.rvm/gems/ruby-2.2.2/gems/sunspot_rails-2.0.0/lib/sunspot_rails.rb:4:in `require'
/home/vaibhav/.rvm/gems/ruby-2.2.2/gems/sunspot_rails-2.0.0/lib/sunspot_rails.rb:4:in `<top (required)>'
/home/vaibhav/.rvm/gems/ruby-2.2.2/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `require'
/home/vaibhav/.rvm/gems/ruby-2.2.2/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
/home/vaibhav/.rvm/gems/ruby-2.2.2/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `each'
/home/vaibhav/.rvm/gems/ruby-2.2.2/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `block in require'
/home/vaibhav/.rvm/gems/ruby-2.2.2/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `each'
/home/vaibhav/.rvm/gems/ruby-2.2.2/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `require'
/home/vaibhav/.rvm/gems/ruby-2.2.2/gems/bundler-1.10.6/lib/bundler.rb:134:in `require'
/home/vaibhav/Mirraw/testing_solr/config/application.rb:7:in `<top (required)>'
/home/vaibhav/Mirraw/testing_solr/Rakefile:4:in `require'
/home/vaibhav/Mirraw/testing_solr/Rakefile:4:in `<top (required)>'
/home/vaibhav/.rvm/gems/ruby-2.2.2/gems/rake-11.1.1/lib/rake/rake_module.rb:28:in `load'
/home/vaibhav/.rvm/gems/ruby-2.2.2/gems/rake-11.1.1/lib/rake/rake_module.rb:28:in `load_rakefile'
/home/vaibhav/.rvm/gems/ruby-2.2.2/gems/rake-11.1.1/lib/rake/application.rb:689:in `raw_load_rakefile'
/home/vaibhav/.rvm/gems/ruby-2.2.2/gems/rake-11.1.1/lib/rake/application.rb:94:in `block in load_rakefile'
/home/vaibhav/.rvm/gems/ruby-2.2.2/gems/rake-11.1.1/lib/rake/application.rb:176:in `standard_exception_handling'
/home/vaibhav/.rvm/gems/ruby-2.2.2/gems/rake-11.1.1/lib/rake/application.rb:93:in `load_rakefile'
/home/vaibhav/.rvm/gems/ruby-2.2.2/gems/rake-11.1.1/lib/rake/application.rb:77:in `block in run'
/home/vaibhav/.rvm/gems/ruby-2.2.2/gems/rake-11.1.1/lib/rake/application.rb:176:in `standard_exception_handling'
/home/vaibhav/.rvm/gems/ruby-2.2.2/gems/rake-11.1.1/lib/rake/application.rb:75:in `run'
/home/vaibhav/.rvm/gems/ruby-2.2.2/gems/rake-11.1.1/bin/rake:33:in `<top (required)>'
/home/vaibhav/.rvm/gems/ruby-2.2.2/bin/rake:23:in `load'
/home/vaibhav/.rvm/gems/ruby-2.2.2/bin/rake:23:in `<main>'
/home/vaibhav/.rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:15:in `eval'
/home/vaibhav/.rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:15:in `<main>'

这是我的 gem 文件,

source 'https://rubygems.org'

gem 'rails', '4.2.2'

gem 'sqlite3'

gem 'sass-rails', '~> 5.0'

gem 'uglifier', '>= 1.3.0'

gem 'coffee-rails', '~> 4.1.0'

gem 'jquery-rails'

gem 'turbolinks'

gem 'jbuilder', '~> 2.0'

gem 'sdoc', '~> 0.4.0', group: :doc

gem 'sunspot_rails'


group :development, :test do
  gem 'byebug'

  gem 'web-console', '~> 2.0'

  gem 'spring'

end

有没有人有办法解决这个问题。

这似乎是 known problem. The problem is that Rails 4.1 renamed a file in ActiveSupport core extensions and sunspot_rails is still trying to include the old file name. This was resolved in this sunspot_rails commit but it still was not merged sunspot_rails gem 的稳定 2.0 分支。

总的来说,这个 gem 似乎被完全放弃了,所以你唯一的选择是尝试直接从 github 使用 gem 的 master 分支,而不是稳定的 2.0 分支。

您可以通过更新您的 Gemfile 来做到这一点,而不是:

gem 'sunspot_rails'

它会说:

gem 'sunspot_rails :github => 'sunspot/sunspot'

查看更多说明here