47

In general, the question I have is the question in the title:

How do I find out which rails version an existing rails application is built on?

More specifically for my purposes, I would like to know how to find out in the case when there is no gemfile (I'm relatively new to rails and used to seeing the rails version in the gemfile with all the rails 3 apps, but am not sure for older versions.)

John
  • 13,125
  • 14
  • 52
  • 73
  • 2
    For those who don't have the same restrictions as the OP, you can find the version in the `Gemfile`. E.g. `gem 'rails', '4.0.2'` – Dennis Feb 26 '14 at 14:57

6 Answers6

48

Use the command: rake about. This command will output the following info plus more (hence the ellipsis:

About your application's environment
Rails version             4.2.0
Ruby version              2.2.2-p95 (x86_64-darwin14) 
RubyGems version          2.4.6
...
Conor Livingston
  • 905
  • 1
  • 8
  • 17
27

rake gems will print out what gems, dependencies, and versions are installed, frozen, etc.

If you are using bundler than you can use bundle show to list all the gems that your app is using.

Raghu
  • 2,543
  • 1
  • 19
  • 24
  • 4
    When I run this, I get: "rake aborted! Don't know how to build task 'gems'" – John Oct 19 '12 at 20:07
  • Yes, and seems to work on the Rails 2.3 app, cus it reports a message saying "Missing the Rails 2.3.8 gem. . . " – John Oct 19 '12 at 20:10
  • 1
    if you are using bundler than bundle show is the command to go for – Raghu Oct 19 '12 at 20:12
  • which means in your environment.rb your app is expecting the rails 2.3.8 gems but it not able find it on your system. – Raghu Oct 19 '12 at 20:13
  • Can you add the part about bundle show to your answer? Will accept it then. – John Oct 19 '12 at 20:21
  • This failed for me like "...rake aborted! can't activate , already activated subexec-0.2.3" however the other answer seemed to work as a replacement when this one doesn't... – rogerdpack Nov 09 '13 at 20:57
6

In my project rake gems do not display the rails version but it's display at the top of the environment.rb file :

RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION
Adrien Coquio
  • 4,870
  • 2
  • 24
  • 37
  • Is there some sort of command I can use to get this, rather than running `cat config/environment.rb | grep RAILS_GEM`? – Goldentoa11 Nov 18 '13 at 15:22
6

Execute this command

bundle show rails

or

rails -v
ABN
  • 1,024
  • 13
  • 26
4

With an open rails console (for example, if you are on the server that runs the application) you could call Rails.version or Rails.gem_version for a short info or Rails::Info for a more complete overview about your environment.

Source: SO#59255712

einjohn
  • 457
  • 5
  • 14
0

If you are using bundler, a more up to date way to do this than bundle show rails is bundle info rails or bundle info [gem-name-here]. This will print version, summary of gem's purpose, link for gem project (if it exists), and your local path for the gem. Super convenient.

(bundle show [gem-name-here] is deprecated.)

aronmoshe_m
  • 908
  • 1
  • 6
  • 15