direnv / direnv

unclutter your .profile
http://direnv.net
MIT License
12.33k stars 631 forks source link

`has rvm` always returns true #1008

Open ziadsawalha opened 1 year ago

ziadsawalha commented 1 year ago

Describe the bug has rvm always returns true because stdlib defines rvm()

To Reproduce On a machine without rvm installed, the following .envrc says ""✅ 'rvm' is detected":

if has rvm; then
  echo "✅ 'rvm' is detected"
else
  echo "❌ 'rvm' not detected"
fi

Expected behavior has rvm should not return true (or document an alternative method to detect if rvm is available)

Environment

Additional context Add any other context about the problem here.

zimbatm commented 1 year ago

Yes, it's unfortunate. I should change the has() definition to type -p "$1" >/dev/null so it only returns true when there is a command. But it would break back-compat and we don't break back-compa.

The best is to replace the rvm check with if type -p rvm >/dev/null; then ...