简体   繁体   English

Gemfile Twitter +法拉第

[英]Gemfile Twitter + Faraday

In my Gemfile 在我的Gemfile中

source 'https://rubygems.org'
ruby '2.1.0'
gem 'rails', '4.0.1'
gem "faraday"
gem "faraday_middleware"
gem "twitter", github: 'sferik/twitter'

if I run 如果我跑

$ bundle install

I get 我懂了

Bundler could not find compatible versions for gem "faraday": In Gemfile: Bundler找不到与宝石“ faraday”兼容的版本:在Gemfile中:

 twitter (>= 0) ruby depends on faraday (~> 0.9.0) ruby faraday (0.8.9) 

TL;DR: Try running bundle update . TL; DR:尝试运行bundle update

Bundler tries to find gems that match in such a way that all their dependencies also match. Bundler试图找到匹配的宝石,使得它们的所有依赖项也都匹配。 So consider this: 所以考虑一下:

  • gem A v1 depends on B v1 宝石A v1取决于宝石B v1
  • gem A v2 depends on B v2 宝石A v2取决于宝石B v2
  • gem C v1 depends on B v1 宝石C v1取决于B v1
  • there is no version of C that knows how to handle B v2. 没有C版本知道如何处理B v2。

In this case, Bundler will choose (or even downgrade) A to v1, so that you can A and C running next to each other. 在这种情况下,Bundler将选择(甚至降级)A到v1,以便A和C彼此相邻运行。

However there are a couple of things that might prevent this from happening, and that will cause the error you are seeing: 但是,有几件事可能会阻止这种情况的发生,并且会导致您看到的错误:

  1. There is no A v1, so no match can be made at all. 没有A v1,因此根本无法进行匹配。 You're stuck in this case, those gems will not work together at all. 在这种情况下,您将陷入困境,这些宝石根本无法协同工作。
  2. You've already installed A v2 and you are adding C later. 您已经安装了A v2,并且稍后将添加C。 This means Bundler needs to downgrade A, but it doesn't do downgrades/upgrades when only running bundle install . 这意味着Bundler需要降级A,但仅运行bundle install时并不需要降级/升级。 You'd have to specifically say that it needs to recalculate the dependencies by running bundle update A or for all the gems in your gemfile: bundle update . 您必须特别指出,它需要通过运行bundle update A或对gemfile: bundle update所有gem重新计算依赖性。
  3. One of the gems is from a git repository. 一颗宝石来自git存储库。 Git repositories don't really have versions like gems hosted on rubygems.org do. Git仓库实际上并没有rubygems.org上托管的gem之类的版本。 This means that Bundler will only fetch the latest version and cannot downgrade that gem. 这意味着Bundler将仅获取最新版本,而无法降级该gem。 You need to specify a branch or revision manually in this case. 在这种情况下,您需要手动指定分支或修订版。

My guess is that you are looking at scenario 2. You've already installed (and locked down on) version 0.8.9 of faraday. 我的猜测是您正在研究场景2。您已经安装了法拉第0.8.9版(并已将其锁定)。 By adding twitter, your previous lock needs to be updated. 通过添加推特,您之前的锁需要更新。

Be careful of running bundle update without arguments however. 但是,请谨慎运行不带参数的bundle update It will try to get the latest versions of every gem in your gemfile, which might not be what you want. 它将尝试获取您的gemfile中每个宝石的最新版本,而这可能不是您想要的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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