简体   繁体   中英

Passing in Gem Version Not Working Rails 4.2

I am trying to install Sunspot for a full text search of my rails app.

When passing in gems and specific versions to the gem file

gem 'sunspot_rails', '~> 2.1.0'
gem 'sunspot_solr', '~> 2.1.0'

it ignores the version and installs 2.1.1 - I have also tried manually installing them from the command prompt

gem install sunspot_rails -v "~> 2.1.0"

but the same thing happens.

Any help as to why this is happening would be greatly appreciated. Any questions please ask. And yes I am still a rails beginner. Thank you!

This happens because of the ~> before the version number. It will install any versions from 2.1.0 to 2.2 (exclusive).

If you want to install exactly the version 2.1.0, remove ~> :

gem 'sunspot_rails', '2.1.0'
gem 'sunspot_solr', '2.1.0'

Some examples on dependency specifiers:

Specification From  ... To (exclusive)
">= 3.0"      3.0   ... ∞
"~> 3.0"      3.0   ... 4.0
"~> 3.0.0"    3.0.0 ... 3.1
"~> 3.5"      3.5   ... 4.0
"~> 3.5.0"    3.5.0 ... 3.6
"~> 3"        3.0   ... 4.0

Check this doc for more details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM