同时使用2个版本的宝石 [英] Use 2 versions of gem at same time

查看:68
本文介绍了同时使用2个版本的宝石的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在一个应用程序中使用两个版本的宝石吗?我试图使用两个rails插件一起工作:


  1. Pengwynn's LinkedIn https://github.com/pengwynn/linkedin 对oauth(〜> 0.3.5)具有依赖性。

  2. OmniAuth for用户通过多个着名网站登录,对oauth 0.4.0有依赖性

当我在rails中尝试某些东西时,出现此错误消息:

  $ rails服务器
c:/Ruby187/lib/ruby/gems/1.8/gems/bundler-1.0 .7 / lib / bundler / resolver.rb:129:在'resolve'中:Bundler无法找到与gemoauth兼容的版本:(Bundler :: VersionConflict)
在快照(Gemfile.lock)中:
oauth(0.4.4)

在Gemfile中:
linkedin取决于
oauth(〜> 0.3.5)

正在运行`bundle update`会从头开始重建你的快照,只使用
Gemfile中的宝石,这可能会解决冲突。

尝试绑定更新只会冻结我的终端

是否可以同时使用这两个插件?

解决方案

使用两个版本的单个gem通常意味着:use两个版本的相同的类。



不修改这些宝石是不可能的。您可以尝试将创建的类放置在某个模块中,解决导入其他类的方法中的冲突,等等。一般来说,这不是一件容易的事,通常效果不值得。



你应该在这种情况下做什么,或者尝试自己做。



也许你可以将这些宝石之一降级(使用旧版本),或者依赖关系是相同的。


Can i use two versions of a gem in one application? I'm trying to use two rails plugins to work together:

  1. Pengwynn's LinkedIn https://github.com/pengwynn/linkedin for LinkedIn API calls, has an dependency on oauth (~> 0.3.5)
  2. OmniAuth for user login via multiple well-known websites, has an dependency on oauth 0.4.0

When i try something in rails i get this error message:

$ rails server
c:/Ruby187/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/resolver.rb:129:in `resolve': Bundler could not find compatible versions for gem "oauth": (Bundler::VersionConflict)
  In snapshot (Gemfile.lock):
    oauth (0.4.4)

  In Gemfile:
    linkedin depends on
      oauth (~> 0.3.5)

Running `bundle update` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.

Trying bundle update just freezes my terminal

Is it possible to use these both plugins at the same time?

解决方案

Using two versions of a single gem usually means: use two versions of the same class.

It's not possible without making modifications to these gems. You may try to place created classes in some module, resolve conflicts in methods imported into other classes, and so on. In general, it is not easy task, and usually the effect is not worth it.

What you should do in such cases is to ask the gem maintainers to update the dependencies, or try to do it yourself.

Maybe you can downgrade (use older version of) one of these gems, to the version in which the dependencies were the same.

这篇关于同时使用2个版本的宝石的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆