How to tell which version of a gem a rails app is

2019-01-21 21:24发布

I'm investigating a rails app - the prod server has two version of a specific gem installed, how can I tell which version the prod app is using?

12条回答
乱世女痞
2楼-- · 2019-01-21 21:28

Try using script/about. Your config/environment.rb also has information about it.

In your config/environment.rb you can specify which version of a particular gem the application should use. However if you have multiple versions of a gem installed on your machine and you do not specify the version, the latest version of that gem will be used by the application.

查看更多
走好不送
3楼-- · 2019-01-21 21:33
gem list <gemname>

It will show all the matching gems e.g if some one do

gem list rack

Then th output will be as following

*** LOCAL GEMS ***

rack (1.6.4)
rack-mount (0.6.14)
rack-test (0.6.3, 0.6.2, 0.5.7)
查看更多
你好瞎i
4楼-- · 2019-01-21 21:37

There probably is a more direct way to find this out, but if you load up a console and require a specific version like so:

gem 'RedCloth', '3.0.4'

It will tell you what version is already activated:

=> Gem::LoadError: can't activate RedCloth (= 3.0.4, runtime) for [], already activated RedCloth-4.2.2
查看更多
地球回转人心会变
5楼-- · 2019-01-21 21:39

try this one for local gem :

gem list gemname | grep -P '(^|\s)\Kgemname(?=\s|$)'

If you use bundle:

bundle exec gem list gemname | grep -P '(^|\s)\Kgemname(?=\s|$)'
查看更多
ゆ 、 Hurt°
6楼-- · 2019-01-21 21:40
bundle exec gem which gem_name

Is probably what you can use:

$› bundle exec gem which rails
/Users/xxxx/.rvm/gems/ruby-2.1.2@gemset/gems/railties-4.1.7/lib/rails.rb
查看更多
ゆ 、 Hurt°
7楼-- · 2019-01-21 21:44

In Gemfile , there should be the answer:

gem 'rails', '4.0.0.rc1'
查看更多
登录 后发表回答