pixi
pixi copied to clipboard
pixi shell-hook and pixi run environment mismatch (GOROOT)
Checks
-
[X] I have checked that this issue has not already been reported.
-
[X] I have confirmed this bug exists on the latest version of pixi, using
pixi --version.
Reproducible example
# pixi.toml
[project]
name = "bla"
version = "0.1.0"
description = "bla"
authors = ["bla"]
channels = ["conda-forge"]
platforms = ["linux-64", "win-64"]
[dependencies]
go = ">=1.22.3,<1.23"
$ pixi --version
pixi 0.24.2
$ pixi info
Pixi version: 0.24.2
Platform: win-64
Virtual packages: __win=0=0
: __cuda=12.2=0
: __archspec=1=skylake
Cache dir: C:\Users\user2\AppData\Local\rattler/cache
Auth storage: C:\Users\user2\.rattler\credentials.json
Project
------------
Name: bla
Version: 0.1.0
Manifest file: C:\Users\user2\bla\pixi.toml
Config locations:
Last updated: 18-06-2024 23:01:07
Environments
------------
Environment: default
Features: default
Channels: conda-forge
Dependency count: 1
Dependencies: go
Target platforms: linux-64, win-64
❯ pixi -vvv shell-hook --shell bash | grep GOROOT
DEBUG pixi::config: Loading config from C:\ProgramData\pixi\config.toml
DEBUG pixi::config: Failed to load system config: C:\ProgramData\pixi\config.toml (error: failed to read config from 'C:\ProgramData\pixi\config.toml')
DEBUG pixi::config: Loading config from C:\Users\user2\.config\pixi\config.toml
DEBUG pixi::config: Failed to load global config: C:\Users\user2\.config\pixi\config.toml (error: failed to read config from 'C:\Users\user2\.config\pixi\config.toml')
DEBUG pixi::config: Loading config from C:\Users\user2\AppData\Roaming\pixi\config.toml
DEBUG pixi::config: Failed to load global config: C:\Users\user2\AppData\Roaming\pixi\config.toml (error: failed to read config from 'C:\Users\user2\AppData\Roaming\pixi\config.toml')
DEBUG pixi::config: Loading config from C:\Users\user2\.pixi\config.toml
DEBUG pixi::config: Failed to load global config: C:\Users\user2\.pixi\config.toml (error: failed to read config from 'C:\Users\user2\.pixi\config.toml')
DEBUG pixi::config: Loading config from C:\Users\user2\bla\.pixi\config.toml
DEBUG pixi::config: Failed to load local config: C:\Users\user2\bla\.pixi\config.toml (error: failed to read config from 'C:\Users\user2\bla\.pixi\config.toml')
INFO pixi::environment: verifying prefix location is unchanged, with prefix file: C:\Users\user2\bla\.pixi\envs\default\conda-meta\pixi_env_prefix
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: _go_select
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: go
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: go-task
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: just
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: m2w64-gcc-libgfortran
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: m2w64-gcc-libs
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: m2w64-gcc-libs-core
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: m2w64-gmp
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: m2w64-libwinpthread-git
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: msys2-conda-epoch
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: nodejs
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: _go_select
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: _libgcc_mutex
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: _openmp_mutex
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: ca-certificates
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: go
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: go-task
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: icu
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: just
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: libgcc-ng
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: libgfortran-ng
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: libgfortran5
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: libgomp
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: libstdcxx-ng
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: libuv
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: libzlib
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: nodejs
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: openssl
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: zlib
INFO pixi::lock_file::update: the lock-file is up-to-date
DEBUG pixi::environment: Wrote environment file to: "C:\\Users\\user2\\bla\\.pixi\\envs\\default\\conda-meta\\pixi"
INFO pixi::environment: Creating prefix file at: C:\Users\user2\bla\.pixi\envs\default\conda-meta\pixi_env_prefix
INFO pixi::environment: No update needed for the prefix file.
INFO pixi::environment: Checking if history file exists: C:\Users\user2\bla\.pixi\envs\default\conda-meta\history
INFO pixi::lock_file::resolve::uv_resolution_context: uv keyring provider is disabled
❯ pixi -vvv run env | grep GOROOT
DEBUG pixi::config: Loading config from C:\ProgramData\pixi\config.toml
DEBUG pixi::config: Failed to load system config: C:\ProgramData\pixi\config.toml (error: failed to read config from 'C:\ProgramData\pixi\config.toml')
DEBUG pixi::config: Loading config from C:\Users\user2\.config\pixi\config.toml
DEBUG pixi::config: Failed to load global config: C:\Users\user2\.config\pixi\config.toml (error: failed to read config from 'C:\Users\user2\.config\pixi\config.toml')
DEBUG pixi::config: Loading config from C:\Users\user2\AppData\Roaming\pixi\config.toml
DEBUG pixi::config: Failed to load global config: C:\Users\user2\AppData\Roaming\pixi\config.toml (error: failed to read config from 'C:\Users\user2\AppData\Roaming\pixi\config.toml')
DEBUG pixi::config: Loading config from C:\Users\user2\.pixi\config.toml
DEBUG pixi::config: Failed to load global config: C:\Users\user2\.pixi\config.toml (error: failed to read config from 'C:\Users\user2\.pixi\config.toml')
DEBUG pixi::config: Loading config from C:\Users\user2\bla\.pixi\config.toml
DEBUG pixi::config: Failed to load local config: C:\Users\user2\bla\.pixi\config.toml (error: failed to read config from 'C:\Users\user2\bla\.pixi\config.toml')
INFO pixi::environment: verifying prefix location is unchanged, with prefix file: C:\Users\user2\bla\.pixi\envs\default\conda-meta\pixi_env_prefix
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: _go_select
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: _libgcc_mutex
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: _openmp_mutex
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: ca-certificates
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: go
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: go-task
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: icu
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: just
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: libgcc-ng
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: libgfortran-ng
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: libgfortran5
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: libgomp
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: libstdcxx-ng
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: libuv
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: libzlib
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: nodejs
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: openssl
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: zlib
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: _go_select
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: go
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: go-task
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: just
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: m2w64-gcc-libgfortran
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: m2w64-gcc-libs
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: m2w64-gcc-libs-core
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: m2w64-gmp
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: m2w64-libwinpthread-git
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: msys2-conda-epoch
DEBUG pixi::lock_file::package_identifier: Using backwards compatibility purl logic for conda package: nodejs
INFO pixi::lock_file::update: the lock-file is up-to-date
DEBUG pixi::cli::run: Task parsed from run command: ["env"]
INFO pixi::cli::run: Task graph: TaskGraph: number of nodes: 1, nodes: task: CUSTOM COMMAND, environment: default, command: `env`, additional arguments: ``, depends-on: ``
INFO pixi::task::executable_task: Checking if task can be skipped
DEBUG pixi::environment: Wrote environment file to: "C:\\Users\\user2\\bla\\.pixi\\envs\\default\\conda-meta\\pixi"
INFO pixi::environment: Creating prefix file at: C:\Users\user2\bla\.pixi\envs\default\conda-meta\pixi_env_prefix
INFO pixi::environment: No update needed for the prefix file.
INFO pixi::environment: Checking if history file exists: C:\Users\user2\bla\.pixi\envs\default\conda-meta\history
INFO pixi::lock_file::resolve::uv_resolution_context: uv keyring provider is disabled
GOROOT=C:\Users\user2\bla\.pixi\envs\default\go
# Export activation environment - applying broken path fix on Git Bash (MSYS2)
❯ eval "$(pixi shell-hook --shell bash | sed 's/^export [Pp][Aa][Tt][Hh]=/export PATH=/I; s/;/:/g')"
❯ which go
/c/Users/user2/bla/.pixi/envs/default/bin/go
❯ env | grep GOROOT
❯ go version
go: cannot find GOROOT directory: 'go' binary is trimmed and GOROOT is not set
❯ pixi run which go
/c/Users/user2/bla/.pixi/envs/default/bin/go
❯ pixi run env | grep GOROOT
GOROOT=C:\Users\user2\sdl\labs\sdl-web\sdl-web-demo-7\.pixi\envs\default\go
❯ pixi run go version
go version go1.22.3 windows/amd64
Issue description
I'm running in a Git Bash environment (i.e. MSYS2) on Windows.
I apply the above mentioned sed to the shell-hook output, to fixup the PATH: #417
I expect that go version and pixi run go version should produce the same results.
I expect that env | grep GOROOT and pixi run env | grep GOROOT should produce the same results.
Maybe this PR is related: #1507
Expected behavior
The behaviour after a shell-hook export and inside a pixi run should be the same:
❯ pixi run go version
go version go1.22.3 windows/amd64
❯ eval "$(pixi shell-hook --shell bash | sed 's/^export [Pp][Aa][Tt][Hh]=/export PATH=/I; s/;/:/g')"
❯ go version
go version go1.22.3 windows/amd64
The GOROOT environment variable must be present in both environments.
After a little debugging I found that the reason is that the GOROOT variable is set by an activation script. The activation script for windows is not found by the Activator when creating a shell-hook script for bash. For bash the activation script must be a bash activation script.
When using pixi run we run the activation with CmdExe behind the scenes which is why with pixi run the variable is set.
You can observe this behavior when you run pixi shell-hook --shell cmd an extra line is added to the shell hook that looks something like:
@CALL "<path>\.pixi\envs\default\etc/conda/activate.d\activate_z60-go.bat
Im a little unsure what to do in this case.
- We could streamline this behavior between
shell-hookandrunby also running the activation in the background forshell-hookfor the OSes native shell. This is slower though and might not capture all the intricacies of the activation scripts. E.g. if a package does something special for bash this wont be included. - We could leave as is. Perhaps updating the go feedstock to not use activation scripts?
@ruben-arts @wolfv WDYT?
If we allow to turn off the activation (which counts for all activating tools), point one should be the best options. As it's in the conda spec we should implement it as best we can.
I looked into it a bit more, I think we should do one or two things:
- modify the way activation works to use the JSON env var approach in the
go-selectfeedstock: https://github.com/conda-forge/_go_select-feedstock/blob/7f1234ad779687d31bea38c719e365479735e43b/recipe/meta.yaml - I can make a PR tomorrow. - or generate the activation scripts using something like
multisheller- @traversaro has done this in Gazebo, for example: https://github.com/conda-forge/libignition-gazebo-feedstock/blob/main/recipe/activate.msh - that generates activation scripts for a number of shells.