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

pixi shell-hook and pixi run environment mismatch (GOROOT) #1527

Open
2 tasks done
W1M0R opened this issue Jun 20, 2024 · 2 comments
Open
2 tasks done

pixi shell-hook and pixi run environment mismatch (GOROOT) #1527

W1M0R opened this issue Jun 20, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@W1M0R
Copy link

W1M0R commented Jun 20, 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

# 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.

@W1M0R W1M0R added the bug Something isn't working label Jun 20, 2024
@W1M0R W1M0R changed the title pixi shell-hook environment mismatch (GOROOT) pixi shell-hook and pixi run environment mismatch (GOROOT) Jun 20, 2024
@baszalmstra baszalmstra self-assigned this Jul 8, 2024
@baszalmstra
Copy link
Contributor

baszalmstra commented Jul 8, 2024

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.

  1. We could streamline this behavior between shell-hook and run by also running the activation in the background for shell-hook for 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.
  2. We could leave as is. Perhaps updating the go feedstock to not use activation scripts?

@ruben-arts @wolfv WDYT?

@ruben-arts
Copy link
Contributor

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.

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

3 participants