alire-project / alire

Command-line tool from the Alire project and supporting library
GNU General Public License v3.0
278 stars 49 forks source link

Overlapping cases in manifest don't err nor match #1729

Open reznikmm opened 1 month ago

reznikmm commented 1 month ago

Describe the bug environment.'case(os)'.'...' is ignored (doesn't match?) on Mac OS X.

To Reproduce I want to build a crate with HEAD of gnatcoll-core. I do

  1. Clone and pin:
    git clone https://github.com/AdaCore/gnatcoll-core.git gnatcoll
    cp -v gnatcoll.toml gnatcoll/alire.toml
    alr pin gnatcoll --use=./gnatcoll
  2. gnatcoll.toml has
    [environment.'case(os)'.'...'.GPR_PROJECT_PATH]
    prepend = "${CRATE_ROOT}/core:${CRATE_ROOT}/projects:${CRATE_ROOT}/minimal"
  3. But alire doesn't take it into account on Mac OS (but does it on Linux AFAICS). On Linux I see

    detail: Env: gnatcoll (env) prepends '/tmp/test/gnatcoll/core:/tmp/test/gnatcoll/projects:/tmp/test/gnatcoll/minimal' to 'GPR_PROJECT_PATH'

But I don't see this line in Mac OS logs. And GPR_PROJECT_PATH misses core, etc.

See Commit ae36a4e6b22070127db61c9a92df41a9385b16dc in my https://github.com/reznikmm/test repo (mac_env branch).

Expected Behavior I want ... to match Mac OS.

alr version 2.0.1.

alr logs See attached zip from GitHub CI (4_Do something.txt) logs_26807299048.zip

reznikmm commented 1 month ago

If I an not mistaken:

mosteo commented 2 weeks ago

I think the problem comes from a misunderstanding. I've tested a similar setup here and it works as expected. But, after inspecting that gnatcoll.toml, what I see is that there is both ... and .macos. entries. This means that ... is not going to match .macos. because it appears explicitly.

TOML is not the best format for anything not trivial. If you visualize the tree, ... is a sibling of macos and it means "others", not "all". So in your case the not-very-nice remedy is to list all cases explicitly.

This however has unearthed a different bug, which is that when two overlapping cases are used, no error is given, nor either match:

[environment.'case(os)'.'linux'.MOCKVAR_LINUX]
prepend = "OKLINUX"

[environment.'case(os)'.'linux|macos'.MOCKVAR_MULTI]
prepend = "OKMULTI"

Either by themselves work as expected, but both simultaneously don't.