I have installed Valgrind on my Mac; but it didn’t work because the instructions I followed were based on a Linux environment:
when I tried valgrind ls -l
I got:
valgrind: Unknown/uninstalled VG_PLATFORM 'amd64-darwin'
So, I tried via Homebrew:
brew install valgrind
It successfully ran; but when I tried the valgrind command again, the former installation overrided my shell command.
In this situation, how can I properly remove the former Valgrind installation?
As suggested in the comments by @bfontaine, it may just be a hashing issue, and readily solved by running:
hash -r
As further suggested in the comments by @Petesh, your initial installation of the "Linux" package may have introduced a /usr/local/bin/valgrind
, which homebrew would not replace. To see if that is the case, run:
brew doctor
and see if homebrew's valgrind
is unlinked. If it is, follow the good doctor's recommendation and remove the one you incorrectly installed and then relink the homebrew version:
sudo rm /usr/local/bin/valgrind
brew link valgrind
Otherwise, the first thing to do is run:
type valgrind
That will tell you what actually gets run when you run valgrind
.
The next thing is to know that homebrew installs everything in /usr/local/bin
, so if the first command above doesn't tell you /usr/local/bin/valgrind
the problem is either that:
valgrind
is superseded by a function or alias - in which case delete the alias or function, orthat your PATH has been set to include something before /usr/local/bin
that contains valgrind
. So you need to run:
echo $PATH
and check if you have something like /usr/local/my/funky/bin
ahead of /usr/local/bin
- which is the correct one you should have.
If your PATH is wrong, you can set it with a command something like this:
export PATH="/bin:/sbin:/usr/local/bin"
although the exact contents will depend on what you had there before.
Once everything works, if it involved changing your PATH, you should make sure that the PATH is always set that way in your login profile, which may be in one of the following files:
$HOME/.profile
$HOME/.bash_profile
$HOME/.bash_login