asdf: No version is set for command elixir [duplicate]
Asked Answered
R

1

8

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?

Rainier answered 2/9, 2022 at 23:10 Comment(1)
Maybe you should make it your global default using asdf global elixir 1.14.0-rc.1-otp-25, or locally using asdf local elixir 1.14.0-rc.1-otp-25 (which will create a .tool-versions config file in your current directory). Does it fix it?Gastrin
D
18

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.

Duchess answered 4/9, 2022 at 5:53 Comment(2)
I opted for Kiex in the meantime and will have to circle back to this in the future if need be. However, I will mark this as answered because it might just do it. Looks like it makes sense. Thank you, @Adam MillerchipRainier
Important note for plugins besides Elixir: ASDF will look for .tool-versions starting from your working dir up to $HOME. So for certain tools/projects, it may make more sense to go to the project root and set a local version there, e.g., for Terraform.Lifeanddeath

© 2022 - 2024 — McMap. All rights reserved.