pixi icon indicating copy to clipboard operation
pixi copied to clipboard

Trouble using pixi shell if iTerm2 shell integration is used in .zshrc

Open stuarteberg opened this issue 5 months ago • 1 comments

Issue description

(Disclaimer: I'm unsure if this is a pixi bug or really an iTerm2 bug.)

On my Mac, I use iTerm2 with its "shell integration" feature.

The pixi shell command doesn't work if I have enabled iTerm2 shell integration AND I've run it2check in my .zshrc file. When I attempt to run pixi shell, I see a command printed to the screen, but it isn't actually sourced appropriately:

bergs@bergs-lm4 ~ % cd pixi-hello-world
bergs@bergs-lm4 pixi-hello-world % pixi shell
 . "/var/folders/tz/_1qplxc96qs7ttr7wbsp6l0r0000gq/T/pixi_env_CuZ.sh"
bergs@bergs-lm4 pixi-hello-world %

Reproducible example

Below is the entire contents of my .zshrc. (And I have no .zprofile.) If I DON'T call it2check from within my .zshrc file, then pixi shell works as expected. (But I do want to be able to call it2check in .zshrc if possible.)

FWIW, here's the source code for it2check.

# .zshrc

# Enable iTerm2 shell integration
test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"

# Check: iTerm2 detection
# If I remove this, then pixi shell works as expected.
if it2check; then
    echo "You're using iTerm!"
fi

# Enable pixi
export PATH=/Users/bergs/.pixi/bin:$PATH

BTW, I had the same issue when using ssh to log in to a Linux machine on which I use bash instead of zsh. On that machine, my .bashrc file also calls it2check, and pixi shell also fails in the same way.

pixi.toml
[project]
channels = ["conda-forge"]
name = "pixi-hello-world"
platforms = ["osx-64"]

[tasks]
hello = "python hello_world.py"

[dependencies]
python = ">=3.12.5,<4"
Other boilerplate

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.
    • I'm using pixi 0.29.0

Expected behavior

pixi shell should open a subshell in which the correct environment is active.

pixi info

      Pixi version: 0.29.0
          Platform: osx-64
  Virtual packages: __unix=0=0
                  : __osx=13.6.6=0
                  : __archspec=1=skylake
         Cache dir: /Users/bergs/Library/Caches/rattler/cache
      Auth storage: /Users/bergs/.rattler/credentials.json
  Config locations: No config files found

Project
------------
              Name: pixi-hello-world
     Manifest file: /Users/bergs/workspace/pixi-hello-world/pixi.toml
      Last updated: 09-09-2024 15:04:45

Environments
------------
       Environment: default
          Features: default
          Channels: conda-forge
  Dependency count: 1
      Dependencies: python
  Target platforms: osx-64
             Tasks: hello

stuarteberg avatar Sep 09 '24 19:09 stuarteberg