An update to the documentation here:
At the step where you update your path:
# If you're using Zsh
echo 'export PATH="/usr/local/opt/ruby/bin:/usr/local/lib/ruby/gems/3.0.0/bin:$PATH"' >> ~/.zshrc
On Apple M1 the path should be:
echo 'export PATH="/opt/homebrew/opt/ruby/bin:gem environment gemdir`/bin:$PATH"' >> ~/.zshrc
I found the paths here.
Are you missing a backtick there?
If you want to run shell command, backticks are outdated and this is the modern more flexible and clear syntax.
echo 'export PATH="/opt/homebrew/opt/ruby/bin:$(gem environment gemdir)/bin:$PATH"' >> ~/.zshrc
Also I would do it in two lines
GEM_PATH=$(gem environment gemdir)
export PATH="/opt/homebrew/opt/ruby/bin:$GEM_PATH/bin:$PATH"
Also you may be interested in this method that uses Ruby code to find the directory and should achieve the same effect
GEM_PATH="$(ruby -r rubygems -e 'puts Gem.dir')/bin"
export PATH="$GEM_PATH:$PATH"
If you install gems like this
gem install GEM --user-install
Then use Gem.user_dir