Skip to content

Order matters for complex environment variables #1222

Open
@carmenere

Description

Describe The Bug

Documentations says "The ordering of environment variables in cargo-make is not necessarily the same between definition and evaluation. cargo-make instead looks at the values and reorders variables depending on the variables they mention."
But, when I use notation "VAR = { source = ... }" or "VAR = { script = ... }" the order matters.

To Reproduce

  1. Create file pg.toml.
  2. fill the file pg.toml with the following:
[env]
MAJOR = "15"
PG_HBA = { source = "${CARGO_MAKE_RUST_TARGET_OS}", default_value = "/etc/postgresql/${MAJOR}/main/pg_hba.conf", mapping = {"macos" = "${BREW}/var/${SERVICE}/pg_hba.conf"} }
SERVICE = { source = "${CARGO_MAKE_RUST_TARGET_OS}", default_value = "postgresql", mapping = {"macos" = "postgresql@${MAJOR}"} }
BREW = { script = ["brew --prefix"], condition = {platforms = ["mac"]} }

[tasks.echo]
script = '''
echo BREW = ${BREW}
echo SERVICE = ${SERVICE}
echo PG_HBA = ${PG_HBA}
'''
  1. Run command
cargo make --makefile pg.toml echo

Output

[cargo-make] INFO - Build File: pg.toml
[cargo-make] INFO - Task: echo
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: echo
BREW = /opt/homebrew
SERVICE = postgresql@15
PG_HBA = ${BREW}/var/${SERVICE}/pg_hba.conf
[cargo-make] INFO - Build Done in 0.30 seconds.

But I expect output

[cargo-make] INFO - Build File: pg.toml
[cargo-make] INFO - Task: echo
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: echo
BREW = /opt/homebrew
SERVICE = postgresql@15
PG_HBA = /opt/homebrew/var/postgresql@15/pg_hba.conf
[cargo-make] INFO - Build Done in 0.29 seconds.

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions