'Could not find gem' error when specifying

2019-05-29 03:43发布

问题:

I am trying to use this forked version of the searchlogic gem. In my gemfile, I have

gem "searchlogic", :git => "http://github.com/railsdog/searchlogic.git"

when I do bundle install, I get this error:

Could not find gem 'searchlogic (>= 0, runtime)' in http://github.com/railsdog/searchlogic.git (at master).
Source does not contain any versions of 'searchlogic (>= 0, runtime)'

What is causing this error? Thanks for reading.

回答1:

It's because your fork not define searchlogic gem by rd_searchlogic gem. So use in your Gemfile :

gem "rd_searchlogic", 
  :git => "rd_searchlogic.gemspec", 
  :require => "searchlogic"


回答2:

Use:

gem 'rd_searchlogic', :git => 'https://github.com/railsdog/searchlogic.git', :require => 'searchlogic'


回答3:

The .gemspec of your fork might contain a different name to that of the gem on RubyGems, for example when I forked active_merchant on GitHub their .gemspec file had:

s.name         = 'activemerchant'

but the gem is defined as active_merchant on RubyGems so I changed my Gemfile from:

gem "active_merchant", git: "https://github.com/adamwaite/active_merchant.git", require: "active_merchant"

to:

gem "activemerchant", git: "https://github.com/adamwaite/active_merchant.git", require: "active_merchant"

note the lack of _.

All worked perfectly after that. This may be an obscure case, but hope it helps someone!



回答4:

It doesn't look like that gem has been upgraded for Rails3. From the issues listed in Github, it seems that searchlogic is heavily dependent on ActiveRecord2 and may not be easily upgraded for Rails 3. It may be worth looking into an alternative.

Will searchlogic work with Rails 3?

http://github.com/binarylogic/searchlogic/issues/issue/65