Out of nowhere today, when I tried to run
pod install on my machine, it could not be found. Uh… what?
zsh: command not found: pod
The only thing that changed recently was installing the most recent supplemental update. Otherwise, nothing with my configuration or environment has changed. Even more strange is that other Ruby gems seemed to work fine, like
gem list produced the expected output, and I even verified that the
pod binary existed in
~/.gem/bin/ via Finder.
rbenv to manage Ruby versions (installed via
brew). And my
.zprofile contains the following:
export GEM_HOME="$HOME/.gem" export RBENV_ROOT=/usr/local/var/rbenv if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
After searching around and finding terrible advice (see below) on Stack Overflow, I decided to add the following to my
This was the sanest solution I could think of, but I do not know if it is the “most correct”. Now everything works as expected. But I honestly have no idea why this change was required now, and why it was not required before. (Or if I should do something else?) *shrugs* Computers, I guess?
I am not a Ruby expert, so if I should be doing something differently, please let me know.
* * *
The bad advice on Stack Overflow that I saw on numerous posts was to use
sudo, which is considered bad practice for various reasons. Another bad suggestion was specifying the bindir to
/usr/local/bin when installing the gem, which is not typically where you would want gems installed.
# yeah... do NOT do this sudo gem install -n /usr/local/bin cocoapods
Update: a better fix
As expected, there is a better (correct!) way to resolve this, which I discovered after running into issues with this solution.
What prompted the issue was that I needed to switch Ruby versions temporarily to debug an unrelated issue. Much to my dismay, installing and trying to use new Ruby versions (and the gems installed for those versions) via
rbenv was no longer working. This was expected as the output of
gem env home was
~/.gem due to my hack above.
After reviewing the docs for
rbenv, I re-ran
rbenv init and updated my
.zprofile to the following:
export RBENV_ROOT=/usr/local/var/rbenv eval "$(rbenv init -)"
(Note: I decided to remove the
if check for
rbenv because I would rather see an error if
rbenv does not exist.)
Now, when I run
gem env home the output is correct:
Again, I still do not know what happened to initially cause this problem. It was probably a supplemental macOS update that installed overnight or something. Who knows. Anyway, if you come across this problem, this is the right way to resolve it.