From 172307675bfe53377b9ff6a83b893dae72478849 Mon Sep 17 00:00:00 2001 From: Philip Arndt Date: Thu, 1 Sep 2011 14:18:00 +1200 Subject: [PATCH] Improved 'wrong rails version' error message. --- bin/refinerycms | 13 +++++++++---- changelog.md | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/bin/refinerycms b/bin/refinerycms index db492a2f8e..abc6f6bdf5 100755 --- a/bin/refinerycms +++ b/bin/refinerycms @@ -166,19 +166,21 @@ module Refinery exit(1) end + # Get the name and path of the new application + @app_path = Pathname.new(File.expand_path(@input.first)) + @app_name = @app_path.to_s.split(File::SEPARATOR).last + rails_version_in_path = run_command('rails --version', {:cd => false, :bundler => false, :puts => false}).to_s.gsub(/(Rails |\n)/, '') @rails_version_to_use = @options[:rails][:version] || rails_version_in_path if @rails_version_to_use !~ %r{\b#{RAILS_MINOR_VERSION}} puts "\nRails #{@rails_version_to_use} is not supported by Refinery #{::Refinery.version}, " \ "please use Rails #{RAILS_MINOR_VERSION}.x instead." + puts "\nYou can tell Refinery CMS an installed and compatible rails version to use like so:\n" + puts "\nrefinerycms #{@app_name} --rails-version #{RAILS_MINOR_VERSION}" puts "\n" exit(1) end - # Get the name and path of the new application - @app_path = Pathname.new(File.expand_path(@input.first)) - @app_name = @app_path.to_s.split(File::SEPARATOR).last - # Get the refinery path based on this file @refinery_path = Pathname.new(File.expand_path('../../', __FILE__)) @@ -236,6 +238,9 @@ module Refinery # Detect non-success or a blank rails output or starting with "Can't initialize" or "Error" if !$?.success? or rails_output.to_s.length == 0 or rails_output =~ /^(Can't\ initialize|Error)/ puts "\nGenerating Rails application failed. Exiting..." + if run_command('gem list rails', {:cd => false, :puts => false, :ruby => false}) !~ %r{[( ]#{@rails_version_to_use}(.0)*[,\)]} + puts "\nDo you have Rails #{@rails_version_to_use} installed?" + end puts "\n" exit(1) else diff --git a/changelog.md b/changelog.md index 9a0f106d47..82604950b5 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,7 @@ * `refinerycms-core` now depends on rails so that users of 1.0.x can be confident of the entire stack being present as before. [Philip Arndt](https://github.com/parndt) * No longer requiring autotest as a dependency of `refinerycms-testing`. [Philip Arndt](https://github.com/parndt) +* Improved 'wrong rails version' error message on install with a more helpful guide on how to specify a rails version. [Philip Arndt](https://github.com/parndt) * [See full list](https://github.com/resolve/refinerycms/compare/1.0.7...1.0.8) ## 1.0.7 [31 August 2011]