【问题标题】:Using multiple Bundler versions使用多个 Bundler 版本
【发布时间】:2019-07-04 03:19:59
【问题描述】:

我加入了一个使用 bundler 版本 1.17.1 的项目。目前我的系统正在使用 bundler 2.0.2 。我有什么方法可以指定捆绑器版本,就像用rbenv 指定 ruby​​ 版本一样。喜欢的东西:

bundler --global 1.17.1

因此,当我运行命令 bundler -v 时,我将收到结果 1.71.1 而不是 2.0.2

我尝试使用gem uninstall bundler 卸载当前捆绑程序并收到此消息:

$ 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
> 

这让我觉得有一种方法可以让我使用多个捆绑器版本。任何仅用于指出我应该查找的地方的线索将不胜感激。

编辑 1

我尝试了bundle _1.17.1_ --version,但它并没有像我预期的那样工作

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

预期: Bundler 版本 1.17.1

实际: Bundler 版本 2.0.2

【问题讨论】:

    标签: ruby-on-rails ruby rubygems bundler


    【解决方案1】:

    试试这个:

    1) gem install bundler -v 1.17.1

    2) bundle _1.17.1_ install

    【讨论】:

    • 接受!看起来这是唯一的方法:bundle _1.17.1_ install
    • @NguyenYou 很高兴它有帮助:)
    • 它对我不起作用:> file ~/.gems/gems/bundler-1.17.1 输出 /Users/iulian/.gems/gems/bundler-1.17.1: directory> bundle _1.17.1_ --version 输出 Bundler version 2.0.2
    • 这似乎不适用于第二版:bundle _2.*.*_ install
    • @angerhang 你试过bundle update --bundler 吗?
    【解决方案2】:

    您可以使用下划线指定多个捆绑器版本:RubyGems 已经提供了此功能。用下划线指定版本号作为命令行的第一个参数。

    $ 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
    

    在 rbenv 中存在类似问题:https://github.com/rbenv/rbenv/issues/235

    希望对你有帮助

    【讨论】:

    • 这不会改变默认值。每次运行bundle 命令时都需要添加版本_1.17.1_。或者如果你想让bundle命令每次都指向这个版本,你可以在你的rc文件中给它起别名,比如alias bundle='bundle _1.17.1_'
    • bundle _1.3.0_ install 返回Could not find command "_1.3.0_".
    猜你喜欢
    • 1970-01-01
    • 2014-03-20
    • 1970-01-01
    • 1970-01-01
    • 2019-06-01
    • 1970-01-01
    • 2014-06-16
    • 1970-01-01
    • 2019-04-13
    相关资源
    最近更新 更多