2021-07-22 22:26:21 -07:00
# Versions
2019-01-12 09:32:30 -07:00
## Install Version
2021-07-22 22:26:21 -07:00
```shell:no-line-numbers
2019-01-12 09:32:30 -07:00
asdf install < name > < version >
# asdf install erlang 17.3
```
2021-07-22 22:26:21 -07:00
If a plugin supports downloading & compiling from source, you can specify `ref:foo` where `foo` is a specific branch, tag, or commit. You'll need to use the same name and reference when uninstalling too.
2019-01-12 09:32:30 -07:00
2019-11-22 11:37:53 -07:00
## Install Latest Stable Version
2021-07-22 22:26:21 -07:00
```shell:no-line-numbers
2019-11-22 11:37:53 -07:00
asdf install < name > latest
# asdf install erlang latest
```
Install latest stable version that begins with a given string.
2021-07-22 22:26:21 -07:00
```shell:no-line-numbers
2019-11-22 11:37:53 -07:00
asdf install < name > latest:< version >
# asdf install erlang latest:17
```
2019-01-12 09:32:30 -07:00
## List Installed Versions
2021-07-22 22:26:21 -07:00
```shell:no-line-numbers
2019-01-12 09:32:30 -07:00
asdf list < name >
# asdf list erlang
```
2021-07-22 22:26:21 -07:00
Filter versions to those that begin with a given string.
2021-07-06 04:17:00 -07:00
2021-07-22 22:26:21 -07:00
```shell:no-line-numbers
2021-07-06 04:17:00 -07:00
asdf list < name > < version >
# asdf list erlang 17
```
2019-01-12 09:32:30 -07:00
## List All Available Versions
2021-07-22 22:26:21 -07:00
```shell:no-line-numbers
2019-11-27 11:24:54 -07:00
asdf list all < name >
# asdf list all erlang
2019-01-12 09:32:30 -07:00
```
2021-07-22 22:26:21 -07:00
Filter versions to those that begin with a given string.
2019-11-22 11:37:46 -07:00
2021-07-22 22:26:21 -07:00
```shell:no-line-numbers
2019-11-27 11:24:54 -07:00
asdf list all < name > < version >
# asdf list all erlang 17
2019-11-22 11:37:46 -07:00
```
2019-11-22 11:37:52 -07:00
## Show Latest Stable Version
2021-07-22 22:26:21 -07:00
```shell:no-line-numbers
2019-11-22 11:37:52 -07:00
asdf latest < name >
# asdf latest erlang
```
Show latest stable version that begins with a given string.
2021-07-22 22:26:21 -07:00
```shell:no-line-numbers
2019-11-22 11:37:52 -07:00
asdf latest < name > < version >
# asdf latest erlang 17
```
2019-01-12 09:32:30 -07:00
## Set Current Version
2021-07-22 22:26:21 -07:00
```shell:no-line-numbers
2019-03-14 13:49:49 -07:00
asdf global < name > < version > [< version > ...]
2020-06-12 17:43:52 -07:00
asdf shell < name > < version > [< version > ...]
2019-03-14 13:49:49 -07:00
asdf local < name > < version > [< version > ...]
2019-01-12 09:32:30 -07:00
# asdf global elixir 1.2.4
2021-07-06 04:17:00 -07:00
asdf global < name > latest[:< version > ]
asdf local < name > latest[:< version > ]
# asdf global elixir latest
2019-01-12 09:32:30 -07:00
```
`global` writes the version to `$HOME/.tool-versions` .
2020-06-12 17:43:52 -07:00
`shell` set the version to an environment variable named `ASDF_${LANG}_VERSION` , for the current shell session only.
2019-01-12 09:32:30 -07:00
`local` writes the version to `$PWD/.tool-versions` , creating it if needed.
2021-07-22 22:26:21 -07:00
See the `.tool-versions` [file in the Configuration section ](/manage/configuration.md ) for details.
2019-01-12 09:32:30 -07:00
2021-07-22 22:26:21 -07:00
:::warning Alternatively
If you want to set a version only for the current shell session
2019-01-12 09:32:30 -07:00
or for executing just a command under a particular tool version, you
can set an environment variable like `ASDF_${TOOL}_VERSION` .
2021-07-22 22:26:21 -07:00
:::
2019-01-12 09:32:30 -07:00
The following example runs tests on an Elixir project with version `1.4.0` .
The version format is the same supported by the `.tool-versions` file.
2021-07-24 00:14:03 -07:00
```shell:no-line-numbers
2019-01-12 09:32:30 -07:00
ASDF_ELIXIR_VERSION=1.4.0 mix test
```
2021-04-27 00:07:45 -07:00
## Fallback to System Version
To use the system version of tool `<name>` instead of an asdf managed version you can set the version for the tool to `system` .
Set system with either `global` , `local` or `shell` as outlined in [Set Current Version ](#set-current-version ) section above.
2021-07-22 22:26:21 -07:00
```shell:no-line-numbers
2021-04-27 00:07:45 -07:00
asdf local < name > system
# asdf local python system
```
2019-01-12 09:32:30 -07:00
## View Current Version
2021-07-22 22:26:21 -07:00
```shell:no-line-numbers
2019-01-12 09:32:30 -07:00
asdf current
# asdf current
2023-02-06 04:45:13 -07:00
# erlang 17.3 /Users/kim/.tool-versions
# nodejs 6.11.5 /Users/kim/cool-node-project/.tool-versions
2019-01-12 09:32:30 -07:00
asdf current < name >
# asdf current erlang
2023-02-06 04:45:13 -07:00
# erlang 17.3 /Users/kim/.tool-versions
2019-01-12 09:32:30 -07:00
```
## Uninstall Version
2021-07-22 22:26:21 -07:00
```shell:no-line-numbers
2019-01-12 09:32:30 -07:00
asdf uninstall < name > < version >
# asdf uninstall erlang 17.3
```
## Shims
2021-11-18 03:05:27 -07:00
When asdf installs a package it creates shims for every executable program in that package in a `$ASDF_DATA_DIR/shims` directory (default `~/.asdf/shims` ). This directory being on the `$PATH` (by means of `asdf.sh` , `asdf.fish` , etc) is how the installed programs are made available in the environment.
2019-01-12 09:32:30 -07:00
2019-11-27 11:24:54 -07:00
The shims themselves are really simple wrappers that `exec` a helper program `asdf exec` passing it the name of the plugin and path to the executable in the installed package that the shim is wrapping.
2019-01-12 09:32:30 -07:00
2020-05-08 23:22:17 -07:00
The `asdf exec` helper determines the version of the package to use (as specified in `.tool-versions` file, selected by `asdf local ...` or `asdf global ...` ), the final path to the executable in the package installation directory (this can be manipulated by the `exec-path` callback in the plugin) and the environment to execute in (also provided by the plugin - `exec-env` script), and finally it executes it.
2019-01-12 09:32:30 -07:00
2021-07-22 22:26:21 -07:00
::: warning Note
Because this system uses `exec` calls, any scripts in the package that are meant to be sourced by the shell instead of executed need to be accessed directly instead of via the shim wrapper. The two `asdf` commands: `which` and `where` can help with this by returning the path to the installed package:
:::
2019-01-12 09:32:30 -07:00
```shell
# returns path to main executable in current version
source $(asdf which ${PLUGIN})/../script.sh
# returns path to the package installation directory
2023-02-06 04:45:13 -07:00
source $(asdf where ${PLUGIN})/bin/script.sh
2019-01-12 09:32:30 -07:00
```
2019-10-27 10:29:09 -07:00
2021-04-05 09:37:39 -07:00
### By-passing asdf shims
2019-10-27 10:29:09 -07:00
If for some reason you want to by-pass asdf shims or want your environment variables automatically set upon entering your project's directory, the [asdf-direnv ](https://github.com/asdf-community/asdf-direnv ) plugin can be helpful. Be sure to check its README for more details.