prefix-dev / pixi

Package management made easy
https://pixi.sh
BSD 3-Clause "New" or "Revised" License
2.88k stars 156 forks source link

`[activation.env]` variables are not expanded #1481

Open pavelzw opened 3 months ago

pavelzw commented 3 months ago
[project]
name = "tmp.uoycNHLXTf"
channels = ["conda-forge"]
platforms = ["osx-arm64"]

[activation.env]
OPENSSL_DIR = "$CONDA_PREFIX"

[dependencies]
openssl = ">=3.3.1,<3.4"
$ pixi shell-hook -s bash
export PATH="/private/var/folders/rz/q1r4tv0n6ll38q18fbk419mc0000gn/T/tmp.uoycNHLXTf/.pixi/envs/default/bin:..."
export CONDA_PREFIX="/private/var/folders/rz/q1r4tv0n6ll38q18fbk419mc0000gn/T/tmp.uoycNHLXTf/.pixi/envs/default"
export PIXI_ENVIRONMENT_PLATFORMS="osx-arm64"
export PIXI_PROJECT_NAME="tmp.uoycNHLXTf"
export PIXI_EXE="/opt/homebrew/bin/pixi"
export OPENSSL_DIR="$CONDA_PREFIX"
export CONDA_DEFAULT_ENV="tmp.uoycNHLXTf"
export PIXI_IN_SHELL="1"
export PIXI_PROJECT_VERSION="0.1.0"
export PIXI_PROMPT="(tmp.uoycNHLXTf) "
export PIXI_ENVIRONMENT_NAME="default"
export PIXI_PROJECT_ROOT="/private/var/folders/rz/q1r4tv0n6ll38q18fbk419mc0000gn/T/tmp.uoycNHLXTf"
export PIXI_PROJECT_MANIFEST="/private/var/folders/rz/q1r4tv0n6ll38q18fbk419mc0000gn/T/tmp.uoycNHLXTf/pixi.toml"

q1r4tv0n6ll38q18fbk419mc0000gn/T/tmp.uoycNHLXTf
$ pixi shell-hook --json | jq
{
  "environment_variables": {
    "PIXI_IN_SHELL": "1",
    "PIXI_PROMPT": "(tmp.uoycNHLXTf) ",
    "PIXI_PROJECT_VERSION": "0.1.0",
    "PIXI_EXE": "/opt/homebrew/bin/pixi",
    "PIXI_PROJECT_MANIFEST": "/private/var/folders/rz/q1r4tv0n6ll38q18fbk419mc0000gn/T/tmp.uoycNHLXTf/pixi.toml",
    "CONDA_DEFAULT_ENV": "tmp.uoycNHLXTf",
    "PIXI_PROJECT_ROOT": "/private/var/folders/rz/q1r4tv0n6ll38q18fbk419mc0000gn/T/tmp.uoycNHLXTf",
    "PATH": "/private/var/folders/rz/q1r4tv0n6ll38q18fbk419mc0000gn/T/tmp.uoycNHLXTf/.pixi/envs/default/bin:...",
    "PIXI_ENVIRONMENT_NAME": "default",
    "CONDA_PREFIX": "/private/var/folders/rz/q1r4tv0n6ll38q18fbk419mc0000gn/T/tmp.uoycNHLXTf/.pixi/envs/default",
    "PIXI_ENVIRONMENT_PLATFORMS": "osx-arm64",
    "OPENSSL_DIR": "$CONDA_PREFIX",
    "PIXI_PROJECT_NAME": "tmp.uoycNHLXTf"
  }
}

While this being okay for pixi shell-hook -s bash, this doesn't work for pixi shell-hook --json as there is no real order in a JSON object. This breaks activate-environment: true in setup-pixi.

ruben-arts commented 3 months ago

This is indeed how we decided to merge it right now. This does work in the tasks (env = OPENSSL_DIR="$CONDA_PREFIX") as there it is a deno task shell evaluated value. But in the activation env or scripts they are simply send to the activation handler. for shell and shell hook that is the shell itself.

It would be better if we could evaluate the values with the deno_task_shell and then export the values as is. But this would become pretty slow.