Use realpath() to avoid Homebrew not detecting that it is in fact in PATH