0

I was getting an error with my application, so I looked on stack and found an answer undefined method `require_relative' for main:Object (NoMethodError) it said that I should run gem install rails which I did, after I ran that, when I tried to run rails generate controller StaticPages home help --no-test-framework I got an error:

(in /usr/local/rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/rails-0.9.5)
rake aborted!
ERROR: 'rake/rdoctask' is obsolete and no longer supported. Use 'rdoc/task' (available in RDoc 2.4.2+) instead.
/usr/local/rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/rails-0.9.5/Rakefile:3:in `<top (required)>'

It says that I am running rails .95 and even when I ran gem update rails nothing happend

Here is my gemfile

source 'https://rubygems.org'
ruby '2.0.0'

gem 'rails', '4.0.2'

group :development, :test do
  gem 'sqlite3', '1.3.8'
  gem 'rspec-rails', '2.13.1'
end

group :test do
  gem 'selenium-webdriver', '2.35.1'
  gem 'capybara', '2.1.0'
end

gem 'sass-rails', '4.0.1'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.1'
gem 'jquery-rails', '3.0.4'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'

group :doc do
  gem 'sdoc', '0.3.20', require: false
end

group :production do
  gem 'pg', '0.15.1'
  gem 'rails_12factor', '0.0.2'
end
Community
  • 1
  • 1
neils
  • 655
  • 2
  • 6
  • 12
  • try to run `bundle exec rails generate ...` – gotva Jan 15 '14 at 19:52
  • @gotva Do you happen to know why I need to run bundle exec because I have never needed to run that before – neils Jan 15 '14 at 19:57
  • 1
    Actually you should do it for `rails`, `rake`, `rspec` etc. because Bundle knows what exactly versions of gems are used in the APP (Bundler takes versions from `Gemfile.lock`) - it means command will be started from correct source. PS if you haven't read about bundle - read [about bundler](http://bundler.io/) PPS did it help you? – gotva Jan 15 '14 at 20:01
  • @gotva Would the command be `bundle install .. ` to install the new versions of the rake, rspec and rails – neils Jan 16 '14 at 02:24
  • 1
    it depends on your local environment. If you have `Gemfile.lock` and you have already run `bundle install` then NO `bundle` finds already installed gems and will use them. – gotva Jan 16 '14 at 05:55

1 Answers1

0

Try deleting your Gemfile.lock (or perhaps moving it). This worked for me.

Steve Benner
  • 1,679
  • 22
  • 26