DEV Community

rugamaga
rugamaga

Posted on

If you have error logs when starting shell with tfenv on anyenv.

TL;DR

You can use anyenv-tfenv-init.

mkdir -p $(anyenv root)/plugins
git clone https://github.com/rugamaga/anyenv-tfenv-init.git $(anyenv root)/plugins/anyenv-tfenv-init

What is the issue?

If you are using tfenv installed via anyenv,
maybe, you seen in each startup of your shell following message:

No such command 'init'
Usage: tfenv <command> [<options>]

Commands:
   install       Install a specific version of Terraform
   use           Switch a version to use
   uninstall     Uninstall a specific version of Terraform
   list          List all installed versions
   list-remote   List all installable versions

This message is happen by interface mismatch between anyenv and tfenv.
Anyenv expect init subcommand for each *env, but tfenv have no init subcommand.

Each(anyenv, tfenv) upstream repository aware this problem, but no movement for 1~2 years.
https://github.com/tfutils/tfenv/issues/53
https://github.com/anyenv/anyenv/pull/81

How solve it?

tfenv can extend by user, by placing binary named tfenv-* in PATH directories.
This anyenv plugin adapting these interface mismatch by placing tfenv-init.

Top comments (0)