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
Related
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.
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
I was going through my Gemfile updating to the latest releases when I got this error:
Bundler could not find compatible versions for gem "mime-types":
In Gemfile:
rails (= 4.0.2) ruby depends on
mime-types (~> 1.16) ruby
mechanize (= 2.7.3) ruby depends on
mime-types (2.0)
Is it true that Rails 4.0.2 is depending on a much older version of mime-types than a lot of gems that are out there or is there something wrong with my local configuration?
P.S. I tried updating the dependencies with ´bundle update´, but I just got the same error again.
rails requires mime-types with a version of 1.16 or greater, but smaller than 2.0. However, mechanize requires mime-types with a version of 2.0 or greater.
I suggest you drop the mechanize-version to 2.7.2:
gem 'mechanize', '2.7.2'
This will resolve your conflict.
I created a new app in Refinery CMS and followed the instructions according to their guide. http://refinerycms.com/download
But when I go to run rails server, I get errors about gem dependencies. Normally those are easy to fix. But what to do when you have conflicting dependencies? This is one of the errors that I got
Bundler could not find compatible versions for gem "refinerycms-core":
In Gemfile:
refinerycms-blog (~> 2.0.0) ruby depends on
refinerycms-core (~> 2.0.0) ruby
refinerycms (~> 2.1.0) ruby depends on
refinerycms-core (2.1.0)
when I have ran into this problem in the past and I added the specific gem, it then would still give me an error saying that it needed the other gem as well. What am I doing wrong here?
Got a response on Twitter from the people at refinery who sent me this link
https://github.com/refinery/refinerycms/issues/2386#issuecomment-22978992
which says so change the gem to
gem 'refinerycms-blog', github: 'refinery/refinerycms-blog', branch: 'master'
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