RVM: gem update generating write access error for wrong location, under /opt

I’m trying to debug a problem where, even if I do a --login shell, rvm’s gem update returns the correct alias, but attempts to update the wrong location, under /opt. Anyone know why this is happening?


First, we see that the RVM alias is established:

MacbookPro ➜ ~ which gem
gem () {
\typeset result
\typeset rvmrc
rvm_rvmrc_files=("/etc/rvmrc" “$HOME/.rvmrc”)
if [[ -n “${rvm_prefix:-}” ]] && ! [[ “$HOME/.rvmrc” -ef “${rvm_prefix}/.rvmrc” ]]
for rvmrc in “${rvm_rvmrc_files[@]}”
[[ -s “${rvmrc}” ]] && source “${rvmrc}” || true
unset rvm_rvmrc_files
command gem “[email protected]
) || result=$?
hash -r
return ${result:-0}

Then, I try to update the gems and continue to get this error (even with a zsh --login shell):

MacbookPro ➜ ~ gem update
Updating installed gems
Updating actioncable
ERROR: While executing gem … (Gem::FilePermissionError)
You don’t have write permissions for the /opt/local/lib/ruby3.0/gems/3.0.0 directory.

Wrong location, and I wonder where the collision is.