且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何同时使用不同版本的 gem

更新时间:2023-01-04 18:22:34

使用单个gem的两个版本通常意味着:使用同一个类的两个版本.

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.

在这种情况下,你应该应该做的是让 gem 维护者更新依赖关系,或者尝试自己做.

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

也许您可以将其中一个 gem 降级(使用旧版本)到依赖项相同的版本.

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