Home > Mobile >  Debian: "command -v <command>" still returns path after removing the package?
Debian: "command -v <command>" still returns path after removing the package?

Time:02-08

I've uninstalled the stylus package on my Debian by sudo apt-get remove --purge node-stylus.

Now it says when I try to run the stylus command: stylus: command not found. So it works as it should.

But in my scripts I check whether Stylus is installed or not by:

if ! command -v sudo stylus &> /dev/null; then
    echo "ERROR: Stylus is not installed!"
    exit 1
fi

And for some reason command -v stylus still returns /usr/bin/stylus thus the script won't fail.

I checked /usr/bin/ and there is no stylus there.

Could someone explain to me please why does this work like this?

CodePudding user response:

Bash maintains a cache for lookups; you want to do

hash -r stylus

to force it to forget the old value.

Separately, of course, don't use command -v sudo when you actually want command -v stylus, as already pointed out in a comment.

  •  Tags:  
  • Related