Error when doing rails new blah, after a project where I put rails back to an early version
rails was working fine, I could do rails new blah
I wanted to test changing rails versions for a project. My experience up until this point has been that changing the rails version of a project won't change rails globally! So my experience has been that when CDing out of a directory and doing rails -v
I'm still on 5.2.2.1
So I made a project with the aim to push back to rails 0.8.0 (just as a test!)
~/rubymac/test16$ cat Gemfile | grep "^gem 'rails'"
gem 'rails', '0.8.0'
~/rubymac/test16$
and I did bundle update rails
and no error, and I saw in Gemfile.lock that rails 0.8.0 seems to be specified there so I guess that worked that far.
Then I did cd ..
and did rails -v
expecting to (still) see rails 5.2.2.1 which has been my experience in the past when I put a project back to a slightly earlier version of rails. But rails -v
didn't work. And rails new blah123
didn't work either.
~/rubymac$ rails -v
(in /usr/local/lib/ruby/gems/2.5.0/gems/rails-0.8.0)
rake aborted!
LoadError: cannot load such file -- rake/rdoctask
/usr/local/lib/ruby/gems/2.5.0/gems/rails-0.8.0/Rakefile:3:in `<top (required)>'
/usr/local/lib/ruby/gems/2.5.0/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
(See full trace by running task with --trace)
~/rubymac$
and
~/rubymac$ rails new blah2432
(in /usr/local/lib/ruby/gems/2.5.0/gems/rails-0.8.0)
rake aborted!
LoadError: cannot load such file -- rake/rdoctask
/usr/local/lib/ruby/gems/2.5.0/gems/rails-0.8.0/Rakefile:3:in `<top (required)>'
/usr/local/lib/ruby/gems/2.5.0/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
(See full trace by running task with --trace)
~/rubymac$
So I searched and found this question new rails project error Rails 3. which suggested gem install rails -v3.0.9
So I did gem install rails -v5.2.2.1
and it gives no error
~/rubymac$ gem install rails -v5.2.2.1
Successfully installed rails-5.2.2.1
Parsing documentation for rails-5.2.2.1
Done installing documentation for rails after 0 seconds
1 gem installed
~/rubymac$
But rails -v still doesn't work
~/rubymac$ rails -v
(in /usr/local/lib/ruby/gems/2.5.0/gems/rails-0.8.0)
rake aborted!
LoadError: cannot load such file -- rake/rdoctask
/usr/local/lib/ruby/gems/2.5.0/gems/rails-0.8.0/Rakefile:3:in `<top (required)>'
/usr/local/lib/ruby/gems/2.5.0/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
(See full trace by running task with --trace)
~/rubymac$
I do gem list and see what rails versions I have
~/rubymac$ gem list | grep "^rails ("
rails (5.2.2.1, 5.2.2, 5.2.1.1, 5.2.1, 5.2.0, 5.1.6, 5.1.4, 5.0.7.2, 5.0.7.1, 5.0.1, 5.0.0, 0.8.0)
~/rubymac$
I tried uninstalling rails 0.8.0. it also prompted me to remove the executable and I said yes
~/rubymac$ gem uninstall rails -v0.8.0
Remove executables:
rails
in addition to the gem? [Yn] y
Removing rails
Successfully uninstalled rails-0.8.0
~/rubymac$ gem list | grep "^rails ("
rails (5.2.2.1, 5.2.2, 5.2.1.1, 5.2.1, 5.2.0, 5.1.6, 5.1.4, 5.0.7.2, 5.0.7.1, 5.0.1, 5.0.0)
~/rubymac$ rails -v
-bash: /usr/local/bin/rails: No such file or directory
~/rubymac$ gem install rails -v5.2.2.1
Successfully installed rails-5.2.2.1
Parsing documentation for rails-5.2.2.1
Done installing documentation for rails after 0 seconds
1 gem installed
but maybe I went a step too far in saying yes to removing the executable earlier having been prompted because now I get '..rails: no such file or directory'
~/rubymac$ rails -v
-bash: /usr/local/bin/rails: No such file or directory
~/rubymac$
even after trying to install 5.2.2.1
~/rubymac$ gem install rails -v5.2.2.1
Successfully installed rails-5.2.2.1
Parsing documentation for rails-5.2.2.1
Done installing documentation for rails after 0 seconds
1 gem installed
~/rubymac$ rails -v
-bash: /usr/local/bin/rails: No such file or directory
~/rubymac$
Added
I then tried gem uninstall rails, I uninstalled all versions. I then did sudo gem install rails. I started a new terminal window. rails -v
when I do which rails
it says /usr/bin/rails
which is an improvement.
But when I do rails -v it says
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.
~$
~$ gem list | grep rails
coffee-rails (4.2.2, 4.2.1)
jquery-rails (4.3.1, 4.1.1)
rails (5.2.2.1)
rails-controller-testing (0.1.1)
rails-dom-testing (2.0.3, 2.0.2)
rails-html-sanitizer (1.0.4, 1.0.3)
sass-rails (5.0.7, 5.0.6)
sprockets-rails (3.2.1, 3.2.0)
actually grep rail* is better 'cos includes railties as mentioned by Uninstall Rails completely
Also, I am not using any version control manager, no rvm or rbenv