title: Troubleshooting "Permission denied @ rb_sysopen" when attempting to install an earlier version of Rails
body: <h2>Summarizing my problem</h2>
  <ul>
  <li><p>Details about my goal:<br />
  I want to install an older(stable) version of Rails; specifically <code>5.2.5</code>.</p>
  </li>
  <li><p>Describing the expected and actual results:<br />
  I expect my Mac running Big Sur v11.3.1 (apple m1) to install Rails successfully.</p>
  </li>
  </ul>
  <p>The actual result is (presumably) a permission/ownership based error:</p>
  <pre><code>$ gem install rails -v 5.2.5
  ERROR:  While executing gem ... (Errno::EACCES)
      Permission denied @ rb_sysopen - /Users/ayylmao/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/concurrent-ruby-1.1.9/CHANGELOG.md
  </code></pre>
  <p>Obviously I see it's something to do with <code>concurrent-ruby-1.1.9</code>...though I continue to get this error with other gems throughout my efforts to install rails on this new-ish computer.</p>
  <h2>Describing what I've tried:</h2>
  <p><a href="https://stackoverflow.com/a/50181226/8659405">Both solutions here</a> - no help</p>
  <p><a href="https://stackoverflow.com/questions/60426930/errnoeacces-permission-denied-rb-sysopen">i've read this question</a> - no help</p>
  <p><a href="https://stackoverflow.com/questions/17550903/why-do-i-get-a-permission-denied-error-while-installing-a-gem">I've read this question, but it's old</a></p>
  <p>I've begun to explore my PATH:</p>
  <pre><code>/Users/ayylmao/.rbenv/shims:/Users/ayylmao/.rbenv/shims:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
  </code></pre>
  <p>and I've uninstalled previous installations of Rails (and railties), as well as removed rbenv and re-installed (via the usual for me, Homebrew)</p>
  <p>I've run <code>brew doctor</code>, i've updated gems with <code>gem update</code>, i've gotten rid of seemingly superfluous gems with <code>for i in </code>gem list --no-versions<code>; do gem uninstall -aIx $i; done</code>.</p>
  <p>Obviously, i'm at my wits end here...</p>
  <h2>My best guess</h2>
  <p>looking at my <code>$PATH</code> it seems super &quot;sus&quot;...looks like there's some redundancy...but I'm not certain how to troubleshoot it or if that's the correct place to be looking.</p>
  <p>I've dropped most details about my system and environment throughout my question, but here's an agregate:</p>
  <ul>
  <li>MacOS BigSur 11.3.1 (perhaps something to do with Apple's <a href="https://support.apple.com/en-us/HT204899" rel="nofollow noreferrer">SIP</a>?) smh</li>
  <li>zsh</li>
  <li>homebrew</li>
  <li>rbenv</li>
  <li>ruby 2.7.2</li>
  </ul>
  <h2>stating my question without any ambiguity</h2>
  <p>How do I troubleshoot this error &quot;Permission denied @ rb_sysopen&quot; via closer inspection of my <code>$PATH</code>? And is that the most likely culprit?</p>
  <p>What steps would I need to take to go completely &quot;nuclear&quot;?</p>
  <p>PS - full disclosure...yes I have used <code>sudo</code> in some instance of installing rails...though i've quickly uninstalled those versions shortly after installation. I apologize for the irresponsibility. I was not prepared for the Apple SIP and panicked months ago....Also, ZSH was a change for me as well.</p>