|
| 1 | ++++ |
| 2 | +title="Managing tooling version with ASDF" |
| 3 | +date=2023-12-09 |
| 4 | + |
| 5 | +[taxonomies] |
| 6 | +categories = ["Tips", "Tooling"] |
| 7 | +tags = ["ASDF"] |
| 8 | + |
| 9 | +[extra] |
| 10 | +comments = true |
| 11 | ++++ |
| 12 | + |
| 13 | +# The local tooling problem |
| 14 | +I always had issues with managing the versions of the tools I use on my computer. |
| 15 | +Working on multiple projects, open and private sources implies that some tools are not all stuck on the same version. |
| 16 | +So I often end up needing to support multiple versions of the same tool on my computer. |
| 17 | +For example, I usually need to support multiple versions of languages : Go, Python, Java, NodeJS to name a few, |
| 18 | +but also tools like Terraform, Ansible, MySQL, Postgres ... |
| 19 | + |
| 20 | +So I started to use different tools to handler this: |
| 21 | +* [GVM](https://github.com/moovweb/gvm) for Go |
| 22 | +* [Pyenv](https://github.com/pyenv/pyenv) for Python |
| 23 | +* [SDKMAN](https://sdkman.io/) for Java |
| 24 | +* [NVM](https://github.com/nvm-sh/nvm) for NodeJS |
| 25 | +* [Tfenv](https://github.com/tfutils/tfenv) for Terraform |
| 26 | +* ... |
| 27 | + |
| 28 | +And everything worked fine, but everytime I had to use a new language or tool (recently done some Rust for instance), |
| 29 | +I had to find yet another tool. And I had to remember to update them from time to time. |
| 30 | + |
| 31 | +# Introducing ASDF |
| 32 | +That when I found [ASDF](https://asdf-vm.com/): "The Multiple Runtime Version Manager". |
| 33 | +As the name implies it's a tool to allow you to manage multiple versions of your runtimes with one tool. |
| 34 | + |
| 35 | +So I gave it a go, and I was not disappointed. After installing it using `brew install asdf`, |
| 36 | +I was able to install the plugins that I needed, they are all listed in [specific GitHub repository](https://github.com/asdf-vm/asdf-plugins). |
| 37 | +You can run a single command to install a plugin and then you can install specific runtime version pretty easily: |
| 38 | +```bash |
| 39 | +asdf plugin add golang |
| 40 | +asdf golang install 1.21.1 |
| 41 | +``` |
| 42 | + |
| 43 | +And boom I have a new version of Go installed on my computer. |
| 44 | + |
| 45 | +## Using ASDF in your projects |
| 46 | +After you have access to a new version of a runtime, you need to be able to use it in your projects. |
| 47 | +With tools like nvm, you could define a specific `.nvmrc` file in your project to specify the version of NodeJS to use. |
| 48 | +ASDF has a similar feature, you can create a `.tool-versions` file in your project and specify the version of the runtime to use: |
| 49 | +`asdf local golang 1.21.1` for instance will be responsible to populate the `.tool-versions` file with the correct version of Go. |
| 50 | +No more need to create multiple file named differently for each tool as everything is centralized in one file. |
| 51 | + |
| 52 | +## Easy migration |
| 53 | +Adopting a new tool can be challenging in a team, but ASDF makes it easy. |
| 54 | +Indeed, most of the plugins support the non asdf version of the version definition. |
| 55 | +For instance for Go, you can use the `go.mod` file to specify the version of Go to use and ASDF will use it to install the correct version. |
| 56 | +`.nvmrc` is also supported for NodeJS for instance and so on. |
| 57 | + |
| 58 | +That means that you can start using ASDF in your project without forcing your team to install it 🤩 |
| 59 | + |
| 60 | +## Conclusion |
| 61 | +ASDF is now one of the first thing I install on a new computer, it's so easy to switch tool version that I can't live without it anymore. |
| 62 | +I encourage you to give it a go, and if you have any question, feel free to ask them in the comments. |
| 63 | + |
| 64 | +Flo. |
0 commit comments