tfenv should behave the same way as rbenv, pyenv, luaenv etc

Created on 7 Jul 2017  ·  5Comments  ·  Source: tfutils/tfenv

I tried to include tfenv in my dotfiles configuration and the same way I do with pyenv, rbenv etc. I lazy-load those wrappers, so init is executed on first call, here how it looks in shell:

% type -f rbenv
rbenv () {
        unset -f rbenv
        export RBENV_ROOT=$XDG_DATA_HOME/rbenv 
        PATH=$DOTFILES/rbenv/rbenv/bin:$PATH 
        eval "$(command rbenv init -)"
        rbenv $@
}

This function is generated automatically using wrapper at https://github.com/z0rc/dotfiles/blob/master/zsh/rc.d/15_rbpynodlua_env.zsh#L5-L16. Also it defines *ENV_ROOT dir so those wrappers won't be creating top-level dotdir in $HOME (Side note: XDG Base Dir Spec is more than a decade old, but some application still don't honor it, shame)

So I tried to enable tfenv here just to find that it doesn't handle TFENV_ROOT the same way as other wrappers. Other wrappers use *ENV_ROOT folder to store shims, plugins and cache. tfenv literally uses it as indicator where it's installed, which doesn't make much sense as this is automatically detected anyway. Also there is no tfenv init command.

I appreciate that you tried to simplify installation, but in the same way you broke compatibility contract with other wrappers.

moreinfo

Most helpful comment

Most importantly, tfenv should not override /usr/local/bin/terraform or conflict with Terraform proper, but, instead, play with $PATH just like everybody else does it.

All 5 comments

In addition there is no tfenv shell to enable certain version of terraform for current shell session.

Most importantly, tfenv should not override /usr/local/bin/terraform or conflict with Terraform proper, but, instead, play with $PATH just like everybody else does it.

Having these features would make it a useful tool when using it with something like anyenv.

I made a branch that does what rbenv init does (in a super simple form).

https://github.com/jalcine/tfenv/tree/add-init-command

Let me know what else should go in there.

Resolved by #240

Was this page helpful?
0 / 5 - 0 ratings