title: how to remove all remains of a global (sudo) ruby and rails installation for a clean reinstallation?
body: <p>I have installed ruby, then rails. Although the installation of rails ended with a success message, every rails command such als <code>rails -v</code> gave me the output</p>
  <p>&quot;Rails is not currently installed on this system. To get the latest version, simply type:</p>
  <pre><code>$ sudo gem install rails
  </code></pre>
  <p>You can then rerun your &quot;rails&quot; command.&quot;</p>
  <p>I did as the message told me (yes, i know already this was the most stupid thing possible).
  Still rails commands give the same output as before.
  So I deinstalled it and installed first the version manager asdf, then Ruby with the command <code>asdf install ruby 2.7.2</code>. This first worked, but after I installed rails with <code>gem install rails --version=7.0.1</code>, there is still the same problem. With <code>which rails</code>, I get the output <code>/usr/bin/rails</code>, but <code>which ruby</code> throws <code>/Users/&lt;name&gt;/.asdf/shims/ruby</code>
  It looks like Rails is installed in the wrong path. The Rails path is the same as in the old installation. Some debris from that installation seems do direct new installations there, where they do not belong.</p>
  <p>How can I remove everything which might been left from the old and the current installation, to start with a clean system?</p>
  <p>Alls answers I found require RVM or a file like <code>.bashsrc</code>, but I have asdf and a <code>.zshrc</code> file.</p>
  <p>Is <code>/usr/bin/rails</code> needed for the default ruby, or can I delete it?</p>
  <p>My system is Mac OS Monterey 12.3 on a Macbook Pro with Intel processor.</p>
  <p>Unfortunately, I do not remember exactly how I installed Ruby the first time. It was with homebrew.</p>