Haider Ali
Haider Ali

Reputation: 800

Rails Gem Installation Issue

Bundle install won't work if i write following in my gem file

gem 'activerecord-sqlserver-adapter'

i got following errors

Bundler could not find compatible versions for gem "activerecord":
In Gemfile:
activerecord-sqlserver-adapter (~> 4.0.0) ruby depends on
  activerecord (~> 4.0.0) ruby

rails (= 4.1.2) ruby depends on
  activerecord (4.1.2)

but when i install this gem from terminal like

gem install activerecord-sqlserver-adapter

I got following sucess message

Fetching: activerecord-sqlserver-adapter-4.1.0.gem (100%)
Successfully installed activerecord-sqlserver-adapter-4.1.0
1 gem installed

Upvotes: 1

Views: 149

Answers (2)

Nick Veys
Nick Veys

Reputation: 23939

You say you put this:

gem 'activerecord-sqlserver-adapter'

But the bundle statement says this:

In Gemfile:
activerecord-sqlserver-adapter (~> 4.0.0) ruby depends on
...

Did you really put this in your Gemfile?

gem 'activerecord-sqlserver-adapter', '~> 4.0.0'

Because the latest activerecord-sqlserver-adapter supports AR 4.1.x. You could try bundle up activerecord-sqlserver-adapter, to get the latest, or specify '~> 4.1' in your Gemfile.

Upvotes: 1

Simone Carletti
Simone Carletti

Reputation: 176342

There is a difference from installing a gem via bundler and installing a gem directly. When using Bundler, Bundler will resolve the gem dependencies within the context of any other gem included in the Gemfile. Therefore, if both gem A and B depend on C, but they depend on two different versions, Bundler will complain.

In your case, activerecord-sqlserver-adapter depends on activerecord (~> 4.0.0) which means any release 4.0.x, whereas you are using Rails 4.1.2 that depends on activerecord 4.1.2.

activerecord-sqlserver-adapter and rails have the same dependency, but the version mismatches. You either need to downgrade Rails (not recommended), or upgrade the activerecord-sqlserver-adapter dependency. You may need to contact the maintainer of activerecord-sqlserver-adapter, or fork the library.

Upvotes: 1

Related Questions