`hab cli setup` vs `hab studio enter` Interactions


I have a quick question about the hab cli setup command, and expected behaviour. Basically what I did was I unset my HAB_* environment variables, and remove my ~/.hab/etc/cli.toml file (all of this is being run on Linux, but same behaviour is seen on Mac OSX), and then re-ran hab cli setup command, which re-created my ~/.hab/etc/cli.toml with values I expect. Note that I also tested this with latest hab version, 0.68.0.

kmott@kmott-sabayon ~ $ unset HAB_BLDR_URL HAB_AUTH_TOKEN HAB_ORIGIN
kmott@kmott-sabayon ~ $ rm ~/.hab/etc/cli.toml
kmott@kmott-sabayon ~ $ hab cli setup
[ ... input cli parameters ... ]
kmott@kmott-sabayon ~ $ cat ~/.hab/etc/cli.toml
auth_token = "<my_token_value>"
origin = "kmott"
bldr_url = "https://bldr.mycompany.com"

Next, I entered the studio, and noticed that a bunch of the HAB_* envronment variables were not set to expected values, even though cli.toml has correct values.

kmott@kmott-sabayon ~ $ hab studio enter -D
[1][default:/src:0]# echo $HAB_BLDR_URL

[2][default:/src:0]# echo $HAB_AUTH_TOKEN

[3][default:/src:0]# echo $HAB_ORIGIN

Interestingly, the only cli.toml value that “stuck” was HAB_ORIGIN (which may have been defaulted to just my $USER var anyways). I can easily workaround it by setting HAB_* shell variables before doing hab studio enter -D, but the studio behaviour of not picking up the cli.toml vars seems inconsistent.

Is this expected behaviour of the hab studio enter -D vs hab cli setup interaction?

Should my HAB_* variables be set in the studio from values in cli.toml?


I believe that cli.toml only populates select environment variables. You ought to be able to get those variables populated in your environment by adding them to .studiorc : https://www.habitat.sh/docs/reference/#environment-variables

I think this is related to: https://github.com/habitat-sh/habitat/issues/4908

^^ The same kind of problem is being discussed here as well.
seems like of a lot more devs are facing this issue.