2017-01-19 10:30:45 -07:00
|
|
|
# asdf [![Build Status](https://travis-ci.org/asdf-vm/asdf.svg?branch=master)](https://travis-ci.org/asdf-vm/asdf)
|
2018-01-13 19:07:07 -07:00
|
|
|
|
2014-12-18 12:08:02 -07:00
|
|
|
### _extendable version manager_
|
2014-09-29 09:51:09 -07:00
|
|
|
|
2018-11-09 16:43:17 -07:00
|
|
|
Supported languages include Ruby, Node.js, Elixir and [more][plugins].
|
|
|
|
Supporting a new language is as simple as [this plugin API][plugin_api].
|
|
|
|
|
|
|
|
[plugins]: https://github.com/asdf-vm/asdf-plugins
|
|
|
|
[plugin_api]: https://github.com/asdf-vm/asdf/blob/master/docs/creating-plugins.md
|
2014-11-30 06:46:11 -07:00
|
|
|
|
2015-05-11 10:36:25 -07:00
|
|
|
## SETUP
|
2014-11-30 06:46:11 -07:00
|
|
|
|
2014-11-30 20:32:14 -07:00
|
|
|
Copy-paste the following into command line:
|
2014-11-30 06:46:11 -07:00
|
|
|
|
2015-05-11 10:33:05 -07:00
|
|
|
```bash
|
2018-10-07 19:31:42 -07:00
|
|
|
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.6.0
|
2015-05-11 10:33:05 -07:00
|
|
|
```
|
|
|
|
|
2017-10-24 01:33:20 -07:00
|
|
|
Depending on your OS and shell, run the following:
|
2015-05-10 09:51:33 -07:00
|
|
|
|
2017-10-24 01:33:20 -07:00
|
|
|
* Bash on Ubuntu (and other Linux distros):
|
2014-11-30 06:46:11 -07:00
|
|
|
|
2017-10-24 01:33:20 -07:00
|
|
|
```bash
|
|
|
|
echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.bashrc
|
|
|
|
echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc
|
|
|
|
```
|
2015-05-18 22:08:42 -07:00
|
|
|
|
2017-10-24 01:33:20 -07:00
|
|
|
* Bash on macOS:
|
2016-04-18 00:33:14 -07:00
|
|
|
|
2017-10-24 01:33:20 -07:00
|
|
|
```bash
|
|
|
|
echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.bash_profile
|
|
|
|
echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.bash_profile
|
|
|
|
```
|
2018-01-13 19:07:07 -07:00
|
|
|
|
2017-10-24 01:33:20 -07:00
|
|
|
* Zsh:
|
|
|
|
|
2018-11-09 16:43:17 -07:00
|
|
|
If you are using a framework, such as oh-my-zsh, use these lines. (Be sure
|
|
|
|
that if you make future changes to .zshrc these lines remain _below_ the line
|
|
|
|
where you source your framework.)
|
2018-01-13 19:07:07 -07:00
|
|
|
|
2017-10-24 01:33:20 -07:00
|
|
|
```bash
|
|
|
|
echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.zshrc
|
|
|
|
echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.zshrc
|
|
|
|
```
|
2018-01-13 19:07:07 -07:00
|
|
|
|
2018-11-09 16:43:17 -07:00
|
|
|
If you are not using a framework, or if on starting your shell you get an
|
|
|
|
error message like 'command not found: compinit', then add this line before
|
|
|
|
the ones above.
|
2018-01-13 19:07:07 -07:00
|
|
|
|
2018-01-10 19:49:43 -07:00
|
|
|
```bash
|
|
|
|
autoload -Uz compinit && compinit
|
|
|
|
```
|
2018-01-13 19:07:07 -07:00
|
|
|
|
2017-10-24 01:33:20 -07:00
|
|
|
* Fish:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
echo 'source ~/.asdf/asdf.fish' >> ~/.config/fish/config.fish
|
|
|
|
mkdir -p ~/.config/fish/completions; and cp ~/.asdf/completions/asdf.fish ~/.config/fish/completions
|
|
|
|
```
|
2018-11-09 16:43:17 -07:00
|
|
|
Restart your shell so that PATH changes take effect. (Opening a new terminal
|
|
|
|
tab will usually do it.)
|
2016-04-18 00:33:14 -07:00
|
|
|
|
2018-11-09 16:43:17 -07:00
|
|
|
Also if you're having issues with it not detecting the shims you've installed
|
|
|
|
it's most-likely due to the sourcing of above `asdf.bash` or `asdf.fish` not
|
|
|
|
being at the bottom of your `~/.bash_profile`, `~/.zshrc`, or
|
|
|
|
`~/.config/fish/config.fish`. It needs to be sourced *after* you've set your
|
|
|
|
`$PATH.`
|
2018-11-07 12:38:24 -07:00
|
|
|
|
2018-11-09 16:43:17 -07:00
|
|
|
> For most plugins, it is good if you have installed the following packages OR
|
|
|
|
> their equivalent on your OS
|
2015-05-18 22:08:42 -07:00
|
|
|
|
2017-10-24 20:03:03 -07:00
|
|
|
> * **macOS**: Install these via homebrew `coreutils automake autoconf openssl libyaml readline libxslt libtool unixodbc`
|
2015-05-19 01:52:55 -07:00
|
|
|
> * **Ubuntu**: `automake autoconf libreadline-dev libncurses-dev libssl-dev libyaml-dev libxslt-dev libffi-dev libtool unixodbc-dev`
|
2016-06-16 14:14:05 -07:00
|
|
|
> * **Fedora**: `automake autoconf readline-devel ncurses-devel openssl-devel libyaml-devel libxslt-devel libffi-devel libtool unixODBC-devel`
|
2014-11-30 06:46:11 -07:00
|
|
|
|
2015-05-10 09:51:33 -07:00
|
|
|
**That's all ~! You are ready to use asdf**
|
2014-11-30 20:32:14 -07:00
|
|
|
|
2018-01-13 19:07:07 -07:00
|
|
|
---
|
2015-11-04 11:48:44 -07:00
|
|
|
|
2015-05-11 10:36:25 -07:00
|
|
|
## USAGE
|
|
|
|
|
2018-11-09 16:43:17 -07:00
|
|
|
These instructions are for a specific version of asdf. Make sure the version
|
|
|
|
README you refer to matches the version of asdf you have installed. Checkout a
|
|
|
|
specific tagged version in the GitHub branches/tags drop-down if you need to.
|
2018-10-18 18:06:05 -07:00
|
|
|
|
2015-05-17 18:25:35 -07:00
|
|
|
### Manage plugins
|
2014-11-30 20:32:14 -07:00
|
|
|
|
2018-11-09 16:43:17 -07:00
|
|
|
Plugins are how asdf understands how to handle different packages. The [plugins
|
|
|
|
repository][plugins] lists all of the asdf plugins we know of and there is a
|
|
|
|
[super-simple API][plugin_api] for supporting more languages.
|
2014-11-30 06:46:11 -07:00
|
|
|
|
2015-05-17 18:25:35 -07:00
|
|
|
##### Add a plugin
|
2014-11-30 20:32:14 -07:00
|
|
|
|
2017-07-25 17:15:08 -07:00
|
|
|
```bash
|
|
|
|
asdf plugin-add <name>
|
|
|
|
# asdf plugin-add erlang
|
|
|
|
```
|
|
|
|
|
2018-11-09 16:43:17 -07:00
|
|
|
If the plugin you want to install is not part of the plugins repository, you
|
|
|
|
can add it using its repository URL:
|
2017-07-25 17:15:08 -07:00
|
|
|
|
2014-11-30 20:32:14 -07:00
|
|
|
```bash
|
2015-05-17 18:25:35 -07:00
|
|
|
asdf plugin-add <name> <git-url>
|
2017-07-25 17:15:08 -07:00
|
|
|
# asdf plugin-add elm https://github.com/vic/asdf-elm
|
2014-11-30 06:46:11 -07:00
|
|
|
```
|
2014-11-30 20:32:14 -07:00
|
|
|
|
2015-06-14 05:27:32 -07:00
|
|
|
##### List installed plugins
|
|
|
|
|
|
|
|
```bash
|
|
|
|
asdf plugin-list
|
|
|
|
# asdf plugin-list
|
2018-01-14 01:38:00 -07:00
|
|
|
# java
|
|
|
|
# nodejs
|
|
|
|
```
|
|
|
|
|
|
|
|
```bash
|
|
|
|
asdf plugin-list --urls
|
|
|
|
# asdf plugin-list
|
2018-01-13 20:37:48 -07:00
|
|
|
# java https://github.com/skotchpine/asdf-java.git
|
|
|
|
# nodejs https://github.com/asdf-vm/asdf-nodejs.git
|
2015-06-14 05:27:32 -07:00
|
|
|
```
|
|
|
|
|
2015-05-17 18:25:35 -07:00
|
|
|
##### Remove a plugin
|
2014-11-30 20:32:14 -07:00
|
|
|
|
|
|
|
```bash
|
2015-05-17 18:25:35 -07:00
|
|
|
asdf plugin-remove <name>
|
|
|
|
# asdf plugin-remove erlang
|
2014-11-30 06:46:11 -07:00
|
|
|
```
|
|
|
|
|
2015-05-17 18:25:35 -07:00
|
|
|
##### Update plugins
|
2014-11-30 06:46:11 -07:00
|
|
|
|
2014-11-30 20:32:14 -07:00
|
|
|
```bash
|
2015-05-17 18:25:35 -07:00
|
|
|
asdf plugin-update --all
|
2014-11-30 06:46:11 -07:00
|
|
|
```
|
|
|
|
|
|
|
|
If you want to update a specific package, just say so.
|
|
|
|
|
2014-11-30 20:32:14 -07:00
|
|
|
```bash
|
2015-05-17 18:25:35 -07:00
|
|
|
asdf plugin-update <name>
|
|
|
|
# asdf plugin-update erlang
|
2014-11-30 06:46:11 -07:00
|
|
|
```
|
|
|
|
|
2018-11-09 13:26:01 -07:00
|
|
|
##### Update asdf itself
|
|
|
|
|
|
|
|
```bash
|
|
|
|
asdf update
|
|
|
|
```
|
|
|
|
|
|
|
|
If you want the latest changes that aren't yet included in a stable release:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
asdf update --head
|
|
|
|
```
|
|
|
|
|
2015-05-17 18:25:35 -07:00
|
|
|
### Manage versions
|
2014-11-30 06:46:11 -07:00
|
|
|
|
2014-11-30 20:32:14 -07:00
|
|
|
```bash
|
2015-05-11 10:33:05 -07:00
|
|
|
asdf install <name> <version>
|
|
|
|
# asdf install erlang 17.3
|
2014-11-30 06:46:11 -07:00
|
|
|
|
2018-01-13 19:07:07 -07:00
|
|
|
asdf current
|
|
|
|
# asdf current
|
|
|
|
# erlang 17.3 (set by /Users/kim/.tool-versions)
|
|
|
|
# nodejs 6.11.5 (set by /Users/kim/cool-node-project/.tool-versions)
|
|
|
|
|
2016-07-24 08:47:17 -07:00
|
|
|
asdf current <name>
|
|
|
|
# asdf current erlang
|
|
|
|
# 17.3 (set by /Users/kim/.tool-versions)
|
2015-05-27 00:20:23 -07:00
|
|
|
|
2015-05-11 10:33:05 -07:00
|
|
|
asdf uninstall <name> <version>
|
|
|
|
# asdf uninstall erlang 17.3
|
2014-11-30 06:46:11 -07:00
|
|
|
```
|
|
|
|
|
2018-11-09 16:43:17 -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.
|
2015-05-21 21:44:53 -07:00
|
|
|
|
2015-05-11 10:36:25 -07:00
|
|
|
##### Lists installed versions
|
2014-11-30 06:46:11 -07:00
|
|
|
|
2014-11-30 20:32:14 -07:00
|
|
|
```bash
|
2015-05-11 10:33:05 -07:00
|
|
|
asdf list <name>
|
|
|
|
# asdf list erlang
|
2014-11-30 06:46:11 -07:00
|
|
|
```
|
|
|
|
|
2015-05-11 10:36:25 -07:00
|
|
|
##### List all available versions
|
2014-11-30 06:46:11 -07:00
|
|
|
|
2014-11-30 20:32:14 -07:00
|
|
|
```bash
|
2015-05-11 10:33:05 -07:00
|
|
|
asdf list-all <name>
|
|
|
|
# asdf list-all erlang
|
2014-11-30 06:46:11 -07:00
|
|
|
```
|
|
|
|
|
2016-04-24 08:11:33 -07:00
|
|
|
#### View current version
|
|
|
|
|
|
|
|
```bash
|
2016-07-23 05:46:02 -07:00
|
|
|
asdf current <name>
|
|
|
|
# asdf current erlang
|
|
|
|
# 17.3 (set by /Users/kim/.tool-versions)
|
2016-04-24 08:11:33 -07:00
|
|
|
```
|
|
|
|
|
|
|
|
#### Set current version
|
|
|
|
|
|
|
|
```bash
|
|
|
|
asdf global <name> <version>
|
|
|
|
asdf local <name> <version>
|
2017-07-03 13:47:47 -07:00
|
|
|
# asdf global elixir 1.2.4
|
2016-04-24 08:11:33 -07:00
|
|
|
```
|
|
|
|
|
2016-05-13 19:18:55 -07:00
|
|
|
`global` writes the version to `$HOME/.tool-versions`.
|
|
|
|
|
|
|
|
`local` writes the version to `$PWD/.tool-versions`, creating it if needed.
|
2016-04-24 08:11:33 -07:00
|
|
|
|
2018-10-31 03:09:24 -07:00
|
|
|
See [The `.tool-versions` file](#the-tool-versions-file) for details.
|
|
|
|
|
2017-01-20 14:10:24 -07:00
|
|
|
Alternatively, if you want to set a version only for the current shell session
|
|
|
|
or for executing just a command under a particular tool version, you
|
|
|
|
can set an environment variable like `ASDF_${TOOL}_VERSION`.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
```shell
|
|
|
|
ASDF_ELIXIR_VERSION=1.4.0 mix test
|
|
|
|
```
|
|
|
|
|
2018-10-28 05:19:08 -07:00
|
|
|
### Shims
|
|
|
|
|
|
|
|
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` or `asdf.fish`) is
|
|
|
|
how the installed programs are made available in the environment.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
The `asdf-exec` helper determines the version of tha 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.
|
|
|
|
|
|
|
|
Note that 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:
|
|
|
|
|
|
|
|
``` sh
|
|
|
|
# returns path to main executable in current version
|
|
|
|
source $(asdf which ${PLUGIN})/../script.sh
|
|
|
|
|
|
|
|
# returns path to the package installation directory
|
|
|
|
source $(asdf where ${PLUGIN} $(asdf current ${PLUGIN}))/bin/script.sh
|
|
|
|
```
|
|
|
|
|
2015-05-17 18:25:35 -07:00
|
|
|
## The `.tool-versions` file
|
2014-11-30 06:46:11 -07:00
|
|
|
|
2018-11-09 16:43:17 -07:00
|
|
|
Whenever `.tool-versions` file is present in a directory, the tool versions it
|
|
|
|
declares will be used in that directory and any subdirectories.
|
2015-05-21 21:34:41 -07:00
|
|
|
**Global defaults can be set in the file `$HOME/.tool-versions`**
|
|
|
|
|
2015-05-21 21:36:45 -07:00
|
|
|
This is what a `.tool-versions` file looks like:
|
2014-10-19 09:18:48 -07:00
|
|
|
|
|
|
|
```
|
2015-05-21 21:34:41 -07:00
|
|
|
ruby 2.2.0
|
|
|
|
nodejs 0.12.3
|
2014-10-19 09:18:48 -07:00
|
|
|
```
|
|
|
|
|
2015-05-21 21:34:41 -07:00
|
|
|
The versions can be in the following format:
|
|
|
|
|
2018-11-09 16:43:17 -07:00
|
|
|
* `0.12.3` - an actual version. Plugins that support downloading binaries, will
|
|
|
|
download binaries.
|
|
|
|
* `ref:v1.0.2-a` or `ref:39cb398vb39` - tag/commit/branch to download from
|
|
|
|
github and compile
|
|
|
|
* `path:/src/elixir` - a path to custom compiled version of a tool to use. For
|
|
|
|
use by language developers and such.
|
|
|
|
* `system` - this keyword causes asdf to passthrough to the version of the tool
|
|
|
|
on the system that is not managed by asdf.
|
2015-05-21 21:24:37 -07:00
|
|
|
|
2018-11-09 16:43:17 -07:00
|
|
|
To install all the tools defined in a `.tool-versions` file run `asdf install`
|
|
|
|
with no other arguments in the directory containing the `.tool-versions` file.
|
2015-11-17 05:35:17 -07:00
|
|
|
|
2018-11-09 16:43:17 -07:00
|
|
|
Edit the file directly or use `asdf local` (or `asdf global`) which updates it.
|
2016-04-24 08:11:33 -07:00
|
|
|
|
2016-08-13 11:27:27 -07:00
|
|
|
## The `$HOME/.asdfrc` config file
|
|
|
|
|
2018-11-09 16:43:17 -07:00
|
|
|
Add a `.asdfrc` file to your home directory and asdf will use the settings
|
|
|
|
specified in the file. The file should be formatted like this:
|
2016-08-13 11:27:27 -07:00
|
|
|
|
|
|
|
```
|
|
|
|
legacy_version_file = yes
|
|
|
|
```
|
|
|
|
|
|
|
|
**Settings**
|
|
|
|
|
2018-11-09 16:43:17 -07:00
|
|
|
* `legacy_version_file` - defaults to `no`. If set to yes it will cause plugins
|
|
|
|
that support this feature to read the version files used by other version
|
|
|
|
managers (e.g. `.ruby-version` in the case of Ruby's rbenv).
|
2016-08-13 11:27:27 -07:00
|
|
|
|
2018-02-11 15:44:26 -07:00
|
|
|
## Environment Variables
|
|
|
|
|
2018-11-09 16:43:17 -07:00
|
|
|
* `ASDF_CONFIG_FILE` - Defaults to `~/.asdfrc` as described above. Can be set
|
|
|
|
to any location.
|
|
|
|
* `ASDF_DEFAULT_TOOL_VERSIONS_FILENAME` - The name of the file storing the tool
|
|
|
|
names and versions. Defaults to `.tool-versions`. Can be any valid file name.
|
|
|
|
* `ASDF_DATA_DIR` - Defaults to `~/.asdf` - Location where `asdf` install
|
|
|
|
plugins, shims and installs. Can be set to any location before sourcing
|
|
|
|
`asdf.sh` or `asdf.fish` mentioned in the section above.
|
2018-02-11 15:44:26 -07:00
|
|
|
|
2017-10-23 01:06:48 -07:00
|
|
|
## Uninstall
|
|
|
|
|
|
|
|
[Uninstalling asdf is easy](https://github.com/asdf-vm/asdf/blob/master/docs/uninstall.md).
|
|
|
|
|
2017-07-23 00:24:40 -07:00
|
|
|
## Docker images
|
|
|
|
|
2018-11-09 16:43:17 -07:00
|
|
|
The [asdf-alpine][asdf-alpine] and [asdf-ubuntu][asdf-ubuntu] projects are an
|
|
|
|
ongoing effort to provide Dockerized images of some asdf tools. You can use
|
|
|
|
these docker images as base for your development servers, or for running your
|
|
|
|
production apps.
|
|
|
|
|
|
|
|
[asdf-alpine]: https://github.com/vic/asdf-alpine
|
|
|
|
[asdf-ubuntu]: https://github.com/vic/asdf-ubuntu
|
2017-07-23 00:24:40 -07:00
|
|
|
|
2017-07-26 09:05:30 -07:00
|
|
|
## Development
|
|
|
|
|
2018-11-09 16:43:17 -07:00
|
|
|
To develop the project, you can simply `git clone` the master branch. If you
|
|
|
|
want to try out your changes without making change to your installed `asdf`,
|
|
|
|
you can set the `$ASDF_DIR` variable to the path where you cloned the
|
|
|
|
repository, and temporarily prepend the `bin` and `shims` directory of the
|
|
|
|
directory to your path.
|
2017-07-26 09:05:30 -07:00
|
|
|
|
2018-11-09 16:43:17 -07:00
|
|
|
We use [bats](https://github.com/sstephenson/bats) for testing, so make sure
|
|
|
|
`bats test/` passes after you made your changes.
|
2017-07-26 09:05:30 -07:00
|
|
|
|
2017-08-08 11:18:51 -07:00
|
|
|
## Contributing
|
|
|
|
|
|
|
|
See [CONTRIBUTING.md](CONTRIBUTING.md) for the contribution guidelines.
|
|
|
|
|
2014-11-30 06:46:11 -07:00
|
|
|
## Credits
|
2014-10-19 09:18:48 -07:00
|
|
|
|
2017-02-20 11:41:33 -07:00
|
|
|
Me ([@HashNuke](https://github.com/HashNuke)), High-fever, cold, cough.
|
2014-10-19 09:18:48 -07:00
|
|
|
|
2016-03-15 21:59:50 -07:00
|
|
|
Copyright 2014 to the end of time ([MIT License](https://github.com/asdf-vm/asdf/blob/master/LICENSE))
|
2014-12-20 07:05:56 -07:00
|
|
|
|
2016-05-12 21:06:14 -07:00
|
|
|
### Maintainers
|
|
|
|
|
2018-01-13 19:07:07 -07:00
|
|
|
* [@HashNuke](https://github.com/HashNuke)
|
2018-11-09 16:15:01 -07:00
|
|
|
* [@danhper](https://github.com/danhper)
|
2018-01-13 19:07:07 -07:00
|
|
|
* [@Stratus3D](https://github.com/Stratus3D)
|
|
|
|
* [@vic](https://github.com/vic)
|
2016-05-12 21:06:14 -07:00
|
|
|
|
2018-01-13 19:07:07 -07:00
|
|
|
---
|
2014-12-20 07:05:56 -07:00
|
|
|
|
2016-03-15 21:22:07 -07:00
|
|
|
Read the [ballad](https://github.com/asdf-vm/asdf/blob/master/ballad-of-asdf.md).
|