blurstudio / hab

A application environment and launcher
GNU Lesser General Public License v3.0
25 stars 3 forks source link

[Bug]: A config with no distros doesn't respect forced requirements #35

Closed MHendricks closed 10 months ago

MHendricks commented 1 year ago

Summary

If your config file doesn't define or inherit distros, you can't force requirements with hab -r.

Expected Behavior

Given this hab command and the test setup, you should see:

$ hab -r aliased dump app/none -v
WARNING:hab.solvers:Forced Requirement: aliased
Dump of FlatConfig('app/none')
------------------------------------------------
name:  none
uri:  app/none
aliases:  as_dict as_list as_str global
versions:  aliased==2.0
------------------------------------------------

What you actually see(ie no aliases ):

Dump of FlatConfig('app/none')
---------------------------------------
name:  none
uri:  app/none
versions:
---------------------------------------

Steps to Reproduce Behavior

  1. Set HAB_PATH to your tests\site_main.json
  2. Save this to tests\configs\app\app_none.json
    {
    "name": "none",
    "context": ["app"],
    "inherits": false,
    }
  3. Run hab -r aliased dump app/none -v. You should see aliased listed in the versions section, but do not.

Solution

The issue is caused due to FlatConfig.versions early out if self.distros is NotSet. Re-work how forced_requirements is respected, preserving the WARNING:hab.solvers:Forced Requirement: aliased logging warning as this is a developer convenience and should not be used by general users.

I think the forced requirements should be included in distros, but that will take a bit of a refactor.

Environment

hab==0.12.0

Additional Context

See above