Search code examples
ruby-on-railsubunturbenv

Rails 4.2.0 load error on Ubuntu using rbenv


I have installed multiple version of rails on my Ubuntu machine locally using Rbenv. Rails -v command works fine when I use it from some project. It shows the version like "2.3.8". But it shows error when I use Rails command from the main directory. Rails -v or Rails new test_app:

Blockquote

/home/rashed/.rbenv/versions/2.2.1/bin/rails:23:in `load': cannot load such file -- /home/rashed/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/rails-4.2.0/bin/rails (LoadError) from /home/rashed/.rbenv/versions/2.2.1/bin/rails:23:in

Blockquote

. Gem shows these installed rails versions (4.2.0, 2.3.8, 2.3.4) I am using ruby "2.2.1p85".


Solution

  • I also tried re-installing rails but it doesn't worked in this case. I tried this command

     $ gem install railties && rbenv rehash
    

    and this worked for me like charm