hashie gem conflict while require twitter gem - ruby-on-rails

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.

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.

Bundler fails because it can't find compatible version of faraday gem

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

Conflicting gem dependencies for the same gem. ruby depends on refinerycms-core

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'

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

Resources