Bundler fails because it can't find compatible version of faraday gem - ruby-on-rails

I'm trying to install a the instagram-ruby-gem but bundler keeps failing with this error:
Bundler could not find compatible versions for gem "faraday":
In Gemfile:
instagram (>= 0) ruby depends on
faraday (< 0.9, >= 0.7.4) ruby
instagram (>= 0) ruby depends on
faraday (0.9.0)
Here's my Gemfile:
gem 'instagram', git: 'https://github.com/larrylv/instagram-ruby-gem.git'
I am using this specific fork because it fixes the faraday version to be compatible with Rails 4. See the commit here, but here's the change:
- s.add_runtime_dependency('faraday', ['>= 0.7', '< 0.9'])
+ s.add_runtime_dependency('faraday', '>= 0.7.4', '<= 0.9.0')
I already tried bundle update. That did not work. The only faraday version installed is faraday 0.9.0.

I downloaded the forked gem, built it and then installed it. It looks like it went through without any issues on my end. So it is something to do with the environment or a gem conflict issue. I'd check to make sure you don't have any other versions of the gem installed. Do you use RVM by any chance and use gemsets with RVM? As a last resort you could delete the Gemfile.lock, but that is not really recommended. You could look at the Gemfile.lock file as well and look at the faraday references. Perhaps other gems need a certain version and the forked gem you use requires another version? I have run in to that before. It is not fun to try and resolve.
Mike Riley

Related

How to solve Gem compatibly issues in Bundler?

In our rails application, we are using two gems (urbanairship and nylas) that's requiring rest-client. One wants ~> 1.6.7 and the other wants ~> 1.7.1.
The usual bundle udpate and rm Gemfile.lock; bundle install doesn't work.
When Bundler is resolving dependencies, we are getting this:
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies............................................................................................................................................
Bundler could not find compatible versions for gem "rest-client":
In Gemfile:
urbanairship (~> 3.0.1) ruby depends on
unirest (>= 1.1.2, ~> 1.1) ruby depends on
rest-client (~> 1.6.7) ruby
nylas (>= 0) ruby depends on
rest-client (~> 1.7) ruby
We can't use unfortunately a different version of either nylas or urbanairship. The only solution we are seing is forking one of the two and editing the .gemspec to accept the same version of rest-client.
Is there any easier solution?
Finally, ended up following Chris advice.
Forked nylas
https://github.com/hartator/nylas-ruby/
Relaxed Gemfile requirements for rest-client. (was 1.7)
gem 'rest-client', '~> 1.6'
Relaxed nylas.gemspec requirements for rest-client. (was 1.7)
s.add_dependency(%q<rest-client>, ["~> 1.6"])
Relaxed nylas.gemspec runtime requirements for rest-client. (was 1.7)
s.add_runtime_dependency(%q<rest-client>, ["~> 1.6"])
Ran specs, everything was still passing.
Added the altered gem to my application Gemfile
gem 'nylas', git: 'git#github.com:hartator/nylas-ruby.git'
Everything is working. Still wondering if there is a cleaner solution out there.
Ref: https://github.com/hartator/nylas-ruby/commit/f7ff4076e96d8a31e223ca0f12d35811d6e9d811

How to override gem dependency?

I have 2 gems that depend on conflicting versions of hashie (one requires ~> 1.2.0 and the other requires 3.3.1):
Bundler could not find compatible versions for gem "hashie":
In Gemfile:
restforce (>= 0) ruby depends on
hashie (~> 1.2.0) ruby
omniauth (>= 0) ruby depends on
hashie (3.3.1)
I'd like to keep both gems and use the higher version of hashie. Is there a way for me override one of the gem dependencies?
The standard advise is to use the higher version compatible.
I do this way, but I think bundler has a defined command for it.
First remove the line of gem 'omniauth' at your Gemfile. Run bundle install, then you must add again the line with gem 'omniauth' to your Gemfile, run bundle install again.
If you look at Gemfile.lock, this install hashie 2.0.5, the higher compatible.
Edit: why does this work?
First I check omniauth dependencies with hashie: hashie < 4, >= 1.2, then the same with restforce: hashie < 2.1, >= 1.2.0. At this point, I know that any version of hashie between 1.2 and 2.0.x must work. Then we must to remove the constraint at Gemfile.lock of continue using hassie 3.3.1, removing 'omniauth' from Gemfile it's done. After that, when install restforce, the bundler find the new version compatible with restforce '2.0.5'. And when you add again omniauth bundler don't update dependencies that are accomplished.
I think bundle update is actually what you were after. That sorts out dependencies and installs different versions of gems if required, giving you the most up-to-date gems possible.
Be careful however, as updating gems can introduce compatibility issues.

Conflict updating to Rails 3.1.10

I am currently running one of my Rails applications on version 3.1.3. My gemfile always listed:
gem 'rails', '3.1.3'
This worked just fine. In an effort to move to 3.1.10, I changed my Gemfile to the following:
gem 'rails', '~> 3.1.10'
Surprisingly, things break when I run bundle update rails after that change:
Bundler could not find compatible versions for gem "multi_json":
In Gemfile:
twitter (>= 0) ruby depends on
multi_json (~> 1.3) ruby
fnordmetric (>= 0) ruby depends on
multi_json (1.2.0)
Just as a test, I tried changing the gem version to '>= 3.1.0' and that installed without any quims, albeit it went to 3.2, which I'm not ready for just yet on this particular application.
Any suggestions for getting this thing running on 3.1.10 which was released today to address a security vulnerability?
Also an update:
I am having absolutely no trouble stashing Gemfile.lock away and starting from Rails 3.1.4. As soon as I try to go to 3.1.5+, this is where all the trouble begins.
Make the change in your Gemfile to
gem 'rails', '3.1.10'
Then try running
bundle update
instead of
bundle install
I can't see your Gemfile but this should will allow the bundler to try and find compatible Gem matches. If you have hard code a Gem revision you might have to relax it and repeat the update. Good luck!
Looking at the gems, it appears that oauth2 lists "multi_json ~> 1.0" and ActiveSupport 3.1.10 lists "multi_json < 1.3, >= 1.0" as the dependencies, so that should resolve. I've run into strangeness like this and fixed it by running
gem uninstall <relevant gems>
then running bundle install again. So maybe try
gem uninstall oauth2 multi_json activesupport
then bundle install
Edit
gem uninstall twitter multi_json fnordmetric

Is there a way around this gem dependency issue?

I want to use both the twitter gem and the pingdom-client gem in a small api health/status site I need to build.
When I try to bundle install the pingdom-client gem, I get the following error.
Bundler could not find compatible versions for gem "faraday":
In Gemfile:
pingdom-client (>= 0) ruby depends on
faraday (~> 0.5.6) ruby
twitter (>= 0) ruby depends on
faraday (0.8.4)
What are my options for resolving this issue? Or do I need to abandon the use of one of these gems?
There isn't a newer version of pingdom-client available with a better dependency, so you can try creating one on your own.
Uninstall all versions of faraday with gem uninstall faraday
Fork pingdom-client.
Change it's dependency on faraday to (~> 0.8.4) it it's pingdom-client.gemspec
Change your Gemfile line to
gem 'pingdom-client', git: 'url/to/your/git/fork.git'
Run bundle
Check your application to see if all is well with pingdom-client running the newer version of faraday

hashie gem conflict while require twitter gem

Hey when i try to 'require' the gem -> twitter (1.6.2) in my rails app I get an error
can't activate hashie (~> 1.1.0, runtime) for ["twitter-1.6.2"], already activated hashie-1.2.0 for ["instagram-0.8.4"]. I did 'gem list' and saw this hashie (1.2.0, 1.1.0). I removed the 1.1.0 version of hashie and that gave another error RubyGem version error: hashie(1.2.0 not ~> 1.1.0). How do I solve this issue?
You should probably look into upgrading the version of the twitter you're using. 1.6.2 is at least a year old. The gem is now on version 3.x and no longer has the hashie dependency.
If this isn't an option for you, you're really just left with forking the twitter gem source, modifying the 1.6.2 tag to suit your needs by either removing the hashie dependency or raising it's dependency version in twitter.gemspec, and then referring to your git fork in your Gemfile
gem "twitter", git: "git://github.com/...", "1.6.2"
Whether removing or raising the version restriction on the hashie gem dependency, you should re-run the tests for the twitter gem before deploying your site with this change.

Resources