Fix “Permission denied @ rb_file_s_symlink” error of installing homebrew

Today I tried to install homebrew on my macOS Mojave, and came across following errors:

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
......
Already up-to-date.
Error: Failed to link all completions, docs and manpages:
  Permission denied @ rb_file_s_symlink - (../../../Homebrew/completions/zsh/_brew, /usr/local/share/zsh/site-functions/_brew)
Failed during: /usr/local/bin/brew update --force

After refering stackoverflow, I fixed it through following command:

$ sudo chown -R $(whoami) $(brew --prefix)/*