Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order matters for complex environment variables #1222

Open
carmenere opened this issue Jan 25, 2025 · 0 comments
Open

Order matters for complex environment variables #1222

carmenere opened this issue Jan 25, 2025 · 0 comments
Assignees

Comments

@carmenere
Copy link

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants