title: difficulty installing and running rails (/usr/local/bin/rails: No such file or directory), having once reverted back to an early rails version
body: <p>Error when doing rails new blah, after a project where I put rails back to an early version</p>
  
  <p>rails was working fine, I could do <code>rails new blah</code></p>
  
  <p>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 <code>rails -v</code> I'm still on 5.2.2.1</p>
  
  <p>So I made a project with the aim to push back to rails 0.8.0 (just as a test!)</p>
  
  <pre><code>~/rubymac/test16$ cat Gemfile | grep "^gem 'rails'"
  gem 'rails', '0.8.0'
  ~/rubymac/test16$ 
  </code></pre>
  
  <p>and I did <code>bundle update rails</code></p>
  
  <p>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.</p>
  
  <p>Then I did <code>cd ..</code> and did <code>rails -v</code> 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 <code>rails -v</code> didn't work. And <code>rails new blah123</code> didn't work either.</p>
  
  <pre><code>~/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 `&lt;top (required)&gt;'
  /usr/local/lib/ruby/gems/2.5.0/gems/rake-12.3.2/exe/rake:27:in `&lt;top (required)&gt;'
  (See full trace by running task with --trace)
  ~/rubymac$ 
  </code></pre>
  
  <p>and</p>
  
  <pre><code>~/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 `&lt;top (required)&gt;'
  /usr/local/lib/ruby/gems/2.5.0/gems/rake-12.3.2/exe/rake:27:in `&lt;top (required)&gt;'
  (See full trace by running task with --trace)
  ~/rubymac$ 
  </code></pre>
  
  <p>So I searched and found this question <a href="https://stackoverflow.com/questions/6818883/new-rails-project-error-rails-3">new rails project error Rails 3</a>. which suggested <code>gem install rails -v3.0.9</code></p>
  
  <p>So I did <code>gem install rails -v5.2.2.1</code></p>
  
  <p>and it gives no error</p>
  
  <pre><code>~/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$ 
  </code></pre>
  
  <p>But rails -v still doesn't work</p>
  
  <pre><code>~/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 `&lt;top (required)&gt;'
  /usr/local/lib/ruby/gems/2.5.0/gems/rake-12.3.2/exe/rake:27:in `&lt;top (required)&gt;'
  (See full trace by running task with --trace)
  ~/rubymac$ 
  </code></pre>
  
  <p>I do gem list and see what rails versions I have</p>
  
  <pre><code>~/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$ 
  </code></pre>
  
  <p>I tried uninstalling rails 0.8.0.  it also prompted me to remove the executable and I said yes</p>
  
  <pre><code>~/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
  </code></pre>
  
  <p>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'</p>
  
  <pre><code>~/rubymac$ rails -v
  -bash: /usr/local/bin/rails: No such file or directory
  ~/rubymac$ 
  </code></pre>
  
  <p>even after trying to install 5.2.2.1</p>
  
  <pre><code>~/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$ 
  </code></pre>
  
  <p><strong>Added</strong></p>
  
  <p>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</p>
  
  <p>when I do <code>which rails</code> it says <code>/usr/bin/rails</code> which is an improvement.</p>
  
  <p>But when I do rails -v it says</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>actually grep rail* is better 'cos includes railties as mentioned by <a href="https://stackoverflow.com/questions/16164697/uninstall-rails-completely">Uninstall Rails completely</a> </p>
  
  <p>Also, I am not using any version control manager, no rvm or rbenv</p>