Failed to run 'elixir' command error in vs code

For me the solution was to create the file $HOME/.tool-versions with content like this (matching the installed versions in system):

erlang 26.2.5
elixir 1.16.3-otp-26