elixirconfigasdf

asdf: No version is set for command elixir


I use asdf to install Erlang and then Elixir.

asdf install elixir 1.14.0-rc.1-otp-25

This results in:

asdf install elixir 1.14.0-rc.1-otp-25

And then ...

$ elixir
No version is set for command elixir
Consider adding one of the following versions in your config file at 
elixir 1.14.0-rc.1-otp-25
$ |

Which config file is this referring to?


Solution

  • TLDR:

    1. asdf install elixir latest
    2. asdf global elixir latest

    Or in your specific case: asdf global elixir 1.14.0-rc.1-otp-25

    See the Set a Version section of the asdf docs:

    6. Set a Version

    asdf performs a version lookup of a tool in all .tool-versions files from the current working directory up to the $HOME directory. The lookup occurs just-in-time when you execute a tool that asdf manages.

    ::: warning Without a version listed for a tool execution of the tool will error. asdf current will show you the tool & version resolution, or absence of, from your current directory so you can observe which tools will fail to execute. :::

    Global

    Global defaults are managed in $HOME/.tool-versions. Set a global version with:

    asdf global nodejs latest

    $HOME/.tool-versions will then look like:

    nodejs 16.5.0

    Some OSs already have tools installed that are managed by the system and not asdf, python is a common example. You need to tell asdf to pass the management back to the system. The Versions reference section will guide you.

    Local

    Local versions are defined in the $PWD/.tool-versions file (your current working directory). Usually, this will be the Git repository for a project. When in your desired directory execute:

    asdf local nodejs latest

    $PWD/.tool-versions will then look like:

    nodejs 16.5.0

    Using Existing Tool Version Files

    asdf supports the migration from existing version files from other version managers. Eg: .ruby-version for the case of rbenv. This is supported on a per-plugin basis.

    asdf-nodejs supports this via both .nvmrc and .node-version files. To enable this, add the following to your asdf configuration file $HOME/.asdfrc:

    legacy_version_file = yes

    See the configuration reference page for more config options.