asdf icon indicating copy to clipboard operation
asdf copied to clipboard

Allow environment variables to be specified in tool-versions

Open iloveitaly opened this issue 4 years ago • 6 comments

Some projects require additional configuration options for packages to be specified. It would be great if these could be specified in the tool-versions file, allowing a simple asdf install, which would avoid additional installation instructions in a readme.

Describe the solution you'd like

Ability to specify environment variables for specific installations within tool-versions. Something along the lines of:

export PYTHON_CONFIGURE_OPTS="--enable-framework"
python 3.7.10

iloveitaly avatar May 01 '21 17:05 iloveitaly

After thinking about this for a few days, my thoughts are:

I don't like the proposal because it only applies to one use case of the asdf install command (that which reads the .tool-versions file and attempts to install each tool:version pair within). That specific use case of asdf install was added as a utility function to ease the singular specific case of bumping all tools at once in a single project.

This further clouds the usage of asdf install which is most commonly used without a .tool-versions file.

Will leave this open for further discussion.

jthegedus avatar May 22 '21 00:05 jthegedus

Ran into a need for this today. Flutter has a FLUTTER_ROOT env variable that specifies where Flutter is installed. Although I can do something like export FLUTTER_ROOT="$(asdf where flutter)" this executes when my shell session begins, and is always the global install root. When I enter a directory where I am running an asdf local setting, I need to be able to update the FLUTTER_ROOT env variable.

themartorana avatar May 16 '22 17:05 themartorana

You could possibly use something like this: https://github.com/excid3/asdf-vars

RobLoach avatar Aug 30 '22 05:08 RobLoach

Bummer that asdf-vars uses a separate file. https://direnv.net seems like a more mature approach and uses a separate file as well.

iloveitaly avatar Aug 30 '22 14:08 iloveitaly

Bummer that asdf-vars uses a separate file. direnv.net seems like a more mature approach and uses a separate file as well.

There is an integration for direnv - https://github.com/asdf-community/asdf-direnv

jthegedus avatar Aug 30 '22 15:08 jthegedus

Didn't know of direnv! This is great, thanks.

RobLoach avatar Aug 30 '22 16:08 RobLoach

Would like to add my input and say that I'm not for this proposal either. Currently, .tool-versions is strictly declarative and this would make it much more imperative. Not to mention that there will be side effects that will need to be dealt with. I might be a bit biased though, because I'm building a tool that aims to have 100% compatibility with the existing .tool-versions file, so this would make it more difficult.

Also direnv was mentioned, which already solves this perfectly - I myself maintain the popular autoenv, and there are still some unanswered questions related to how and when to "unload" [environment ]variables (and deal with side-effects). So all in all I think its better to delegate this responsibility to a different tool and not implement it yet again in another tool

hyperupcall avatar Oct 16 '22 22:10 hyperupcall

I'd agree here—I think direnv/asdf-vars approach makes more sense given the small scope of the responsibility the .tool-versions has.

iloveitaly avatar Oct 17 '22 19:10 iloveitaly