ASDF - Runtime Version Manager for Multiple Languages
What is ASDF?
ASDF is an extendable version manager that allows you to manage multiple runtime versions with a single CLI tool. It is designed to be simple and easy to use, and it supports a wide range of programming languages and tools.
Installing ASDF
To install ASDF on your Mac, follow these steps:
- Open a terminal window.
- Run the following command to clone the ASDF repository:
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.1
- Add the following line to your shell configuration file (e.g.,
~/.bashrc
,~/.zshrc
, or~/.bash_profile
):
. $HOME/.asdf/asdf.sh
- Restart your terminal or run the following command to apply the changes:
source ~/.bashrc
- Verify that ASDF is installed correctly by running the following command:
asdf --version
If you see the ASDF version number, the installation was successful.
Using ASDF
To use ASDF, you need to install plugins for the programming languages or tools you want to manage. For example, to install the Node.js plugin, run the following command:
asdf plugin-add nodejs
After installing the plugin, you can install specific versions of Node.js using ASDF. For example, to install Node.js version 14.17.0, run the following command:
asdf install nodejs 14.17.0
You can switch between different versions of Node.js using the asdf local
command. For example, to use Node.js version 14.17.0 in the current directory, run the following command:
asdf local nodejs 14.17.0
Switching between Python versions
To switch between Python versions using ASDF, follow these steps:
- Install the Python plugin by running the following command:
asdf plugin-add python
- Install the desired Python version using the following command:
asdf install python 3.10.7
- Set the Python version to use in the current directory by running the following command:
asdf local python 3.10.7
Now you can use the specified Python version in the current directory.
Conclusion
ASDF is a powerful version manager that simplifies the process of managing multiple runtime versions. By following the steps outlined in this guide, you can install ASDF on your Mac and start using it to manage different programming languages and tools with ease. If you have any questions or run into any issues, feel free to consult the official ASDF documentation.