0

Usage case: a git repo for an app contains a .tool-versions file with all the tooling required to the app or to deploy it.

me as a user, or another user might have a preference for additional tooling for this particular project as would rather not have it installed/shimmed as a 'global' but just have it consumed within the repository for the app.

Ideally I am looking for .tool-versions.local where I can add my own tooling alongside the tooling. Is anyone here using a similar workflow, and what is your implementation like?

I've looked into using .envrc and .envrc.local to perform tasks like:

asdf plugin add myplugin
asdf install myplugin latest
asdf local myplugin latest  

the problem here is that the last asdf local... will modify the .tool-versions file. I really want to avoid that

user140090
  • 41
  • 1

1 Answers1

0

The feature doesn't currently exist within asdf, but you can do it yourself by overriding cd. Plop the following in your .bashrc or .zshrc.

cd() {
  ... # Your other commands

  if [ -f '.tool-versions.local' ]; then
    export ASDF_DEFAULT_TOOL_VERSIONS_FILENAME='.tool-versions.local'
  else
    export ASDF_DEFAULT_TOOL_VERSIONS_FILENAME='.tool-versions'
  fi
}

This way, asdf local should override .tool-versions.local if it exists. You may want to add this code to pushd and popd, if you use those builtins as well.

One downside to this approach is that sometimes, in some situations, for some editors, this code may not be ran when you open a new terminal. For VSCode, you can configure it to do so. Other popular editors should have a similar configuration as well.

hyperupcall
  • 869
  • 10
  • 21