- Various development tools (such as CocoaPods, fastlane, twine, etc) are written in Ruby
- Since Ruby is an interpreter we can't just make a binary of needed tools, you have to install it locally
- There is a default system Ruby in macOS which is limited for security reasons
- Therefore it is highly recommended to install a separate virtual environment for Ruby via environment manager
- Most popular managers are rbenv, rvm and chruby
- We have a good experience with rbenv
- Make sure you don't have any other manager/Ruby installed (
which rubyshould outputs/usr/bin/ruby- system Ruby) - If you have other manager/Ruby installed, look into the documentation of your manager and uninstall it completely 🙃
- Install rbenv via Homebrew:
brew install rbenv ruby-build(if you don't have Homebrew go to https://brew.sh/) - Now we have to make sure that both Homebrew and rbenv are loaded into your shell
- This can be done by modifying your
~/.zshrc+~/.zshenvfiles and restarting Terminal (more about zsh configuration here) - For Homebrew:
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zshrc - For rbenv:
echo 'eval "$(rbenv init - zsh)"' >> ~/.zshrc && echo 'export PATH="$HOME/.rbenv/shims:${PATH}"' >> ~/.zshenv - Install and set a required Ruby version, for example:
rbenv install 3.2.2 && rbenv global 3.2.2 - Now you can install and use required gems, for example:
gem install twine🤗