1
votes

I've been following Mike Hartl's excellent Ruby on Rails Tutorial`.

I had to make some decisions earlier about versions for gem files and ruby. I decided (after some problems getting Heroku to work that I'd directly mimic the tutorial and versions of ruby described - leading me to go with rvm use 2.0.0 to set my version of ruby.

All was great on chapter one but now I'm getting an error message when i try to create a new rails project:

$ rails new demo_app

/home/huw/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in require': cannot load such file -- rails/cli (LoadError) from /home/huw/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:inrequire' from /usr/bin/rails:9:in `'

I have no idea what that means... but as its referencing my ruby version I'm guessing that my rails and ruby versions are out of sync...

Could someone advise on possible courses of action?

I imagine possible options would be:

  1. Reset my ruby version to the latest (but I don't know what clashes that would create with gems!)
  2. Downgrade from rails 4.1 to rails 4 (I believe that's Mike Hardl's version)
  3. Force things through somehow

I'm a complete rails Noob however, and have no idea where to begin on any of those options - or if that error code even backs up my assumptions!

3
Did you run gem install rails? If so, what is the output of rails -v> - zwippie
zwippy you had it! So 'rails -v' printed out a repeat of the error message, so I ran 'gem install rails' which appeared to hang before installing. I can now run 'rails new demo_app'. But this leaves me very confused. This laptop already has rails installed. I've been fiddling with projects for a few weeks (and even had chapter one running successfully mere minutes ago) now using rails (using the Rails for Zombies tutorial... Why was it suddenly not found, have i just reinstalled it? :S confused! - Huw
You might have installed rails for your system-wide ruby but not for your RVM setup. That seems to be fixed now. - zwippie

3 Answers

3
votes

Forgive the "answer" but I don't have the rep to post a mere comment :-(

Have you tried looking at the RVM site? It has a troubleshooting page that may help you.

If not, have you tried get rvm stable and then typing in the rails new app_name command?

Other useful RVM commands are rvm list rubies and rvm gemset list. It may be the case that the ruby version you're using doesn't have rails for some reason.

2
votes

As per zwippie's answer in the comment section, the solution was achieved as follows.

rails -v produced a very similar looking output to the error message above.

gem install rails after hanging for a second installed rails successfully. I am now able to add a new project.

I'm unsure why this has happened as I've been successfully making new rails projects both on this laptop and in this directory for the last two weeks, even up until this morning. However as zwippie notes perhaps this is an RVM setup issue. I'll go away and read up but if anyone had any additional pointers from documentation that might shed light on the issue I'm appreciate any links in the comment.

Many thanks all.

0
votes

check for the rails is installed on your machine by the command bundle show rails.

If you get the version of rails and are still getting the above error, to resolve it you may have to use the command bundle exec before every rails command as in bundle exec rails s.