Using multiple Bundler versions

萝らか妹 提交于 2019-12-12 13:32:02

问题


I've joined a project which is using bundler version 1.17.1 . Currently my system is using bundler 2.0.2 . Is there any way for me to specify a bundler version just like specifying ruby version with rbenv. Something likes:

bundler --global 1.17.1

So that, when I run the command bundler -v I will receive the result 1.71.1 rather than 2.0.2

I tried to uninstall the current bundler with gem uninstall bundler and received this message:

$ gem uninstall bundler

Select gem to uninstall:
 1. bundler-1.17.1
 2. bundler-1.17.3
 3. bundler-2.0.2
 4. All versions
> 

That makes me think there is a certain way allows me to work with multiple bundler versions. Any clues just for pointing me to where I should look up would be really appreciated.

EDIT 1

I tried bundle _1.17.1_ --version and it didn't work as I expected

$ bundler -v
Bundler version 2.0.2
$ bundle _1.17.1_ --version
Bundler version 1.17.1
$ bundler -v
Bundler version 2.0.2

expected: Bundler version 1.17.1

actual: Bundler version 2.0.2


回答1:


Try this:

1) gem install bundler -v 1.17.1

2) bundle _1.17.1_ install




回答2:


You can specify multiple bundler versions by using underscores: RubyGems already provides this functionality. Specify the version number in underscores as the first argument on the command line.

$ bundle _1.1.3_ --version
Bundler version 1.1.3
$ bundle _1.1.0_ --version
Bundler version 1.1.0
$ bundle _1.0.22_ --version
Bundler version 1.0.22

There's an issue in rbenv with a similar question: https://github.com/rbenv/rbenv/issues/235.

Hope this helps



来源:https://stackoverflow.com/questions/56880223/using-multiple-bundler-versions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!