setup-pixi icon indicating copy to clipboard operation
setup-pixi copied to clipboard

Windows runner error with `activate-environment: true` when `cxx-compilers` are used

Open Sprychipper opened this issue 1 year ago • 2 comments

Summary

In GHES 3.12 when the option activate-environment: true is used the action crashes with the following error

Activate environment
  ##[debug]Executing: C:\Users\runneradmin\.pixi\bin\pixi.exe shell-hook --json --manifest-path pyproject.toml --color always -vv
  ::endgroup::
C:\actions-runner\_work\_actions\prefix-dev\setup-pixi\v0.8.1\dist\index.js:80992
    throw new Error("Unable to handle environment activation which does not only append to PATH");
          ^

Error: Unable to handle environment activation which does not only append to PATH
    at getNewPathComponents (C:\actions-runner\_work\_actions\prefix-dev\setup-pixi\v0.8.1\dist\index.js:80992:11)
    at activateEnvironment (C:\actions-runner\_work\_actions\prefix-dev\setup-pixi\v0.8.1\dist\index.js:81005:27)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v20.8.1
##[debug]Node Action run completed with exit code 1
##[debug]Finishing: Run prefix-dev/[email protected]

As per comment https://discord.com/channels/1082332781146800168/1082338253925003385/1255141187245834382 the action was rerun and the $Env.PATH values were compared with the path values in the pixi shell-hook --json command and the following difference was seen.

in path the value of an entry is C:\\ghcup\bin and the same in the json:path is C:\\\\ghcup\\bin

Potential issue

The shell hook is escaping the \ character and this results in the discrepancy

Expected

The action works without an issue

Sprychipper avatar Jun 25 '24 16:06 Sprychipper

@pavelzw

After some further investigation, i think i have narrowed it down further. The issue comes actually when the cxx-compilers are used as a dependency. If they are not used then the activate-environment works as expected.

In the below example if the default = { features = ["test", "build"], solve-group = "test" } is replaced with default = { features = ["test"], solve-group = "test" } then the action works as expected. This is only on the windows runners , in linux it works without an issue.

Reproducible example

[project]
name = "testing"
version = "0.1.0"
description = "Add a short description here"
requires-python = ">= 3.11"
dependencies = []

[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[tool.pixi.project]
channels = ["https://fast.prefix.dev/conda-forge"]
platforms = ["linux-64", "win-64"]

[tool.pixi.system-requirements]
linux = "3.10.0"

[tool.pixi.tasks]

[tool.pixi.dependencies]
pip = ">=24.0,<25"
requests = ">=2.31.0,<2.32"

[tool.pixi.feature.build.dependencies]
cxx-compiler = ">=1.7.0,<1.8"

[tool.pixi.feature.test.dependencies]
pytest = ">=8.2.0,<8.3"

[tool.pixi.environments]
default = { features = ["test", "build"], solve-group = "test" }

Sprychipper avatar Jun 29 '24 14:06 Sprychipper

Would be interesting to know whether this is an actual issue in the cxx-compiler activation scripts or whether pixi can be smarter about figuring out the path.

pavelzw avatar Jun 29 '24 15:06 pavelzw

@pavelzw what is required to move this issue forward, i can help with testing . Thanks!

vigneshmanick avatar Aug 19 '24 16:08 vigneshmanick

Hey @Sprychipper @vigneshmanick,

i did some further digging and found out the following.

The package compilers (or cxx-compiler) depends on the vs2019_win-64 package. This package ships a custom activation script that's being executed. In said activation script, a vcvars64.bat (which is shipped in Visual Studio and can't be shipped into conda-forge (probably due to licensing reasons)) is called:

https://github.com/conda-forge/vc-feedstock/blob/00cc29ef719b15969ca2ce52e24769a4b8d8285a/recipe/activate.bat#L135

This script doesn't prepend to PATH but also appends the following to PATH.

C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\Llvm\x64\bin;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\VC\Linux\bin\ConnectionManagerExe;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\vcpkg

There are surely some obscure edge cases where you need to append to PATH as well. setup-pixi unfortunately can't handle this as echo ... >> $GITHUB_PATH only prepends to the PATH and doesn't append. Replacing PATH by doing something like echo PATH=... >> $GITHUB_ENV also is not an option as this will break Windows where the path sometimes needs to look somewhat like /c/Users/runner/env/.pixi/envs/default:... (cygwin) and sometimes like C:\Users\runner\env\.pixi\envs\default;... (powershell, cmd).

So unfortunately, this issue is not fixable by this repo here and also not fixable by pixi. Either change the vc-feedstock activation script or change vcvars64.bat which is probably quite a complicated thing to do.

pavelzw avatar Sep 03 '24 13:09 pavelzw