Recently, I updated my Mac to the latest beta of macOS Catalina. It’s not a polished product yet, but overall it’s been a fairly enjoyable operating system.
One of the changes that will impact you as a developer is that Apple switched the default shell from Bash to Zsh (Z shell). You can, of course, change it back to Bash, but I don’t mind Zsh (or Fish) so I decided to keep it.
I needed to install
$ gem install htmlbeautifier ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory.
For this particular machine, I picked rbenv. Unfortunately, following the usual setup instructions didn’t really work, so I’m sharing the setup that worked for me here.
I updated brew and used it to install
$ brew update && brew install rbenv ruby-build
To ensure that rbenv is correctly loaded when we start a new shell, I had to edit a couple of files. I added the following line to
This adds gem-specific binaries to the PATH so that they are accessible to the shell without fully qualifying them with their path.
Then I added the following lines to
source $HOME/.zshenv eval "$(rbenv init - zsh)"
This ensures that the previous file is sourced when a new session is started and that rbenv is initialized for Zsh.
At this point, you’ll want to source
.zshrc (or simply restart the terminal of your choice like iTerm2, instead):
$ source ~/.zshrc
With rbenv ready to go, I installed the latest version of Ruby and set it as my global default for this machine:
$ rbenv install 2.6.5 $ rbenv global 2.6.5
After restarting my terminal again, I was able to do a quick sanity test to ensure that the right version of Ruby was being selected:
$ ruby -v ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin19] $ ruby -e "puts (1..100).reduce(:+)" 5050
Finally, I was able to install htmlbeautifier:
$ gem install htmlbeautifier
No need for
I hope this helps anyone who is trying to install rbenv on zsh. It did the trick for me.
Get more stuff like this
Subscribe to my mailing list to receive similar updates about programming.
Thank you for subscribing. Please check your email to confirm your subscription.
Something went wrong.