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

Can't modify PATH in env activation table #1465

Open
2 tasks done
beenje opened this issue May 31, 2024 · 1 comment
Open
2 tasks done

Can't modify PATH in env activation table #1465

beenje opened this issue May 31, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@beenje
Copy link
Contributor

beenje commented May 31, 2024

Checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pixi, using pixi --version.

Reproducible example

[project]
name = "myproject"
channels = ["conda-forge"]
platforms = ["osx-64", "linux-64"]

[activation]
env = { PATH = "$PIXI_PROJECT_ROOT/.pixi/envs/tangotest/bin:$PATH" }

[tasks]
echo = { cmd = "echo $PATH" }

[dependencies]
python = ">=3.12.3,<3.13"
pytango = ">=9.5.1,<9.6"

[feature.tangotest]
dependencies = { tango-test = "3.9" }

[environments]
tangotest = { features = ["tangotest"], no-default-feature = true }

Issue description

With pixi 0.23.0 and the new env activation table, I wanted to replace the following pixi.toml:

[project]
name = "myproject"
channels = ["conda-forge"]
platforms = ["osx-64", "linux-64"]

[tasks]
echo = { cmd = "echo $PATH", env = { PATH = "$PIXI_PROJECT_ROOT/.pixi/envs/tangotest/bin:$PATH" } }

[dependencies]
python = ">=3.12.3,<3.13"
pytango = ">=9.5.1,<9.6"

[feature.tangotest]
dependencies = { tango-test = "3.9" }

[environments]
tangotest = { features = ["tangotest"], no-default-feature = true }

With this file, it works:

$ myproject pixi run echo
✨ Pixi task (echo in default): echo $PATH
/Users/benjaminbertrand/tmp/myproject/.pixi/envs/tangotest/bin:/Users/benjaminbertrand/tmp/myproject/.pixi/envs/default/bin:/Users/benjaminbertrand/miniconda/condabin:/usr/local/opt/gnu-sed/libexec/gnubin...

But with the env activation table, this is what I get:

$ pixi run echo
✨ Pixi task (echo in default): echo $PATH
$PIXI_PROJECT_ROOT/.pixi/envs/tangotest/bin:$PATH
$ pixi shell
 . "/var/folders/5p/7800st6d3w76wy6pr67lm9680000gn/T/pixi_env_Ya1.sh"
$  myproject  . "/var/folders/5p/7800st6d3w76wy6pr67lm9680000gn/T/pixi_env_Ya1.sh"
(myproject) $ echo $PATH
/Users/benjaminbertrand/tmp/myproject/.pixi/envs/tangotest/bin:/usr/local/opt/gnu-sed/libexec/gnubin...

.pixi/envs/default/bin isn't part of the PATH.

When looking at shell-hook, it looks ok. I guess there is an issue in how the variables are expanded?

$ pixi shell-hook
export PATH="/Users/benjaminbertrand/tmp/myproject/.pixi/envs/default/bin:/Users/benjaminbertrand/miniconda/condabin:/usr/local/opt/gnused/libexec/gnubin:..."
...
export PATH="$PIXI_PROJECT_ROOT/.pixi/envs/tangotest/bin:$PATH"

Expected behavior

I'd expect the PATH to be identical to when using task env: /Users/benjaminbertrand/tmp/myproject/.pixi/envs/tangotest/bin:/Users/benjaminbertrand/tmp/myproject/.pixi/envs/default/bin:/Users/benjaminbertrand/miniconda/condabin:/usr/local/opt/gnu-sed/libexec/gnubin...

@beenje beenje added the bug Something isn't working label May 31, 2024
@ruben-arts
Copy link
Contributor

Hmm that should be fixable. I also noted that it is placed in between the PIXI_PROJECT_ variables which can then also never work when using them in the PATH. I think it shouldn't be to hard to fix but I don't see a glaring issue when looking at it. As we already use an IndexMap and push them in, in the right order.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants