[英]How to run a specific version of a ruby gem
I am running brakeman outside of my Gemfile, so am not using bundler. 我在我的Gemfile之外运行刹车手,所以我没有使用捆绑器。
If I do gem list
, I can see I have the following for brakeman 如果我做gem list
,我可以看到我有以下制动器
brakeman (3.3.3, 3.3.2, 3.1.4, 3.1.2)
But if I do brakeman --version
, I get 但如果我做brakeman --version
,我得到
brakeman 3.1.2
so I am not using the latest version. 所以我没有使用最新版本。 If I do gem update brakeman
or 如果我做gem update brakeman
或
gem update brakeman, '3.3.3,
I get 我明白了
Updating installed gems
Nothing to update
So how do I run brakeman version 3.3.3? 那么如何运行brakeman版本3.3.3?
If you have several gem versions installed and you want to invoke a specific version from the command-line, you could use: 如果您安装了多个gem版本并且想要从命令行调用特定版本,则可以使用:
brakeman _3.3.3_ [args go here]
This is not specific to brakeman, you can do this for most other gems as well. 这不是制动员特有的,你也可以为大多数其他宝石做这件事。
I can't reproduce this issue, but I can think of a few reasons why this might happen: 我无法重现这个问题,但我可以想到为什么会发生这种情况的几个原因:
.bundle/
) pointing to the old version. Bundler工件(可能在.bundle/
)指向旧版本。 Try running in a different directory and see if it still happens 尝试在不同的目录中运行,看看它是否仍然存在 gem update --system
) RubyGems中的一个错误(尝试gem update --system
) brakeman
binary and you selected "no" 在安装过程中,它询问您是否要更换brakeman
二进制文件并选择“否” rvm
) 如果您使用的是Ruby版本管理器,则可能有一个版本与另一个版本位于不同的路径上(如系统宝石与rvm
管理的rvm
) GEM_PATH
, bundler
, gem
, rvm
weirdness that sometimes occurs 有时会出现任意数量的GEM_PATH
, bundler
, gem
, rvm
怪异 In any case, if I were you I'd gem uninstall brakeman
, remove all versions, and install fresh. 在任何情况下,如果我是你我gem uninstall brakeman
,删除所有版本,并安装新鲜。 If you are using rvm
, start with a fresh gemset or rvm gemset empty
the current one. 如果您使用的是rvm
,请从新的gemset或rvm gemset empty
当前的。
I had a similar problem: I uninstalled a certain gem version, but the version still showed up. 我遇到了类似的问题:我卸载了某个宝石版本,但版本仍然出现了。
TL;DR: rbenv rehash
did the trick. TL; DR: rbenv rehash
完成了这个伎俩。 (Only valid for rbenv
users, obviously) (显然只对rbenv
用户有效)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.