'How to set env variables using ASDF in a Rails project

Rbenv uses rbenv-vars to specify per-application environment variables in Rails.

Most version managers read the .env file in every project for the environment variables.

However, I can't find a way to make asdf-vm and asdf-ruby to read the .env file and export all the env variables in there (or any file with the env variables).

The docs on the same are quite scanty.

How do you set environment variables using asdf-vm or asdf-ruby on a Rails project?



Solution 1:[1]

You can use the plugin asdf-vars for this. The env file is called .asdf-vars and functions the same as a .rbenv-vars file.

As of writing this, you will need to modify asdf's command-exec.bash file to get the plugin to work. There is a discussion here about making the process easier.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 wintermute