Skip to content

Support pixi shell with fish and Windows #4648

@fstanis

Description

@fstanis

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

In MSYS2 bash shell:

$ pacman -S fish

$ fish
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish

$ pixi --version
pixi 0.55.0

$ pixi shell -v
 INFO pixi_core::lock_file::update: the lock-file is up-to-date
 INFO pixi_core::lock_file::update: Environment 'default' is up-to-date with lock file hash
 INFO pixi_cli::shell: Starting shell: Fish(Fish)
Error:   × Unsupported shell: Fish(Fish)

Issue description

I came across a few issues trying pixi in a MSYS2 environment on windows with fish, notably, pixi shell fails saying Unsupported shell: Fish(Fish). However, pixi shell-hook actually works fine and outputs this:

set -gx Path "D:\home\user\git\pixi-project\.pixi\envs\default;D:\home\user\git\pixi-project\.pixi\envs\default\Library/mingw-w64/bin;D:\home\user\git\pixi-project\.pixi\envs\default\Library/usr/bin;D:\home\user\git\pixi-project\.pixi\envs\default\Library/bin;D:\home\user\git\pixi-project\.pixi\envs\default\Scripts;D:\home\user\git\pixi-project\.pixi\envs\default\bin;D:\home\user\.local\bin;D:\home\user\bin;D:\Apps\Git\mingw64\bin;D:\Apps\Git\usr\local\bin;D:\Apps\Git\usr\bin;D:\Apps\Git\usr\bin;D:\Apps\Git\mingw64\bin;D:\Apps\Git\usr\bin"
set -gx CONDA_SHLVL "2"
set -gx CONDA_ENV_SHLVL_2_CONDA_PREFIX "D:\home\user\git\pixi-project\.pixi\envs\default"
set -gx CONDA_PREFIX "D:\home\user\git\pixi-project\.pixi\envs\default"
set -gx CONDA_ENV_SHLVL_2_PIXI_PROJECT_NAME "pixi-project"
set -gx PIXI_PROJECT_NAME "pixi-project"
set -gx CONDA_ENV_SHLVL_2_PIXI_PROJECT_ROOT "D:\home\user\git\pixi-project"
set -gx PIXI_PROJECT_ROOT "D:\home\user\git\pixi-project"
set -gx CONDA_ENV_SHLVL_2_PIXI_PROJECT_MANIFEST "D:\home\user\git\pixi-project\pixi.toml"
set -gx PIXI_PROJECT_MANIFEST "D:\home\user\git\pixi-project\pixi.toml"
set -gx CONDA_ENV_SHLVL_2_PIXI_PROJECT_VERSION "0.1.0"
set -gx PIXI_PROJECT_VERSION "0.1.0"
set -gx CONDA_ENV_SHLVL_2_PIXI_IN_SHELL "1"
set -gx PIXI_IN_SHELL "1"
set -gx CONDA_ENV_SHLVL_2_PIXI_EXE "D:\home\user\.pixi\bin\pixi.exe"
set -gx PIXI_EXE "D:\home\user\.pixi\bin\pixi.exe"
set -gx CONDA_ENV_SHLVL_2_CONDA_DEFAULT_ENV "pixi-project"
set -gx CONDA_DEFAULT_ENV "pixi-project"
set -gx CONDA_ENV_SHLVL_2_PIXI_ENVIRONMENT_NAME "default"
set -gx PIXI_ENVIRONMENT_NAME "default"
set -gx CONDA_ENV_SHLVL_2_PIXI_ENVIRONMENT_PLATFORMS "win-64"
set -gx PIXI_ENVIRONMENT_PLATFORMS "win-64"
set -gx CONDA_ENV_SHLVL_2_PIXI_PROMPT "(pixi-project) "
set -gx PIXI_PROMPT "(pixi-project) "

        function __pixi_add_prompt
            set_color -o green
            echo -n "(pixi-project) "
            set_color normal
        end

        if not functions -q __fish_prompt_orig
            functions -c fish_prompt __fish_prompt_orig
        end

        if functions -q fish_right_prompt
            if not functions -q __fish_right_prompt_orig
                functions -c fish_right_prompt __fish_right_prompt_orig
            end
        else
            function __fish_right_prompt_orig
                # Placeholder function for when fish_right_prompt does not exist
                echo ""
            end
        end

        function fish_prompt
            set -l last_status $status
            if set -q PIXI_LEFT_PROMPT
                __pixi_add_prompt
            end
            __fish_prompt_orig
            return $last_status
        end

        function fish_right_prompt
            if not set -q PIXI_LEFT_PROMPT
                __pixi_add_prompt
            end
            __fish_right_prompt_orig
        end    

However, there are problems with this output:

  • The first line is set -gx Path ... while it should be set -gx PATH since it's case-sensitive.
  • The path is using windows-style paths instead of linux-style (cygpath) ones.
  • The path is separated by semicolons instead of being a fish array.

In the output of pixi shell-hook -s bash, PATH is correctly capitalized and uses linux-style paths:

export PATH="/d/home/user/git/pixi-project/.pixi/envs/default:/d/home/user/git/pixi-project/.pixi/envs/default/Library/mingw-w64/bin:/d/home/user/git/pixi-project/.pixi/envs/default/Library/usr/bin:/d/home/user/git/pixi-project/.pixi/envs/default/Library/bin:/d/home/user/git/pixi-project/.pixi/envs/default/Scripts:/d/home/user/git/pixi-project/.pixi/envs/default/bin:/d/home/user/.local/bin:/d/home/user/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/usr/bin:/mingw64/bin:/usr/bin"
export CONDA_SHLVL=2
export CONDA_ENV_SHLVL_2_CONDA_PREFIX="D:\\home\\user\\git\\pixi-project\\.pixi\\envs\\default"
export CONDA_PREFIX="D:\\home\\user\\git\\pixi-project\\.pixi\\envs\\default"
export CONDA_ENV_SHLVL_2_PIXI_EXE="D:\\home\\user\\.pixi\\bin\\pixi.exe"
export PIXI_EXE="D:\\home\\user\\.pixi\\bin\\pixi.exe"
export CONDA_ENV_SHLVL_2_PIXI_PROJECT_VERSION=0.1.0
export PIXI_PROJECT_VERSION=0.1.0
export CONDA_ENV_SHLVL_2_PIXI_PROJECT_ROOT="D:\\home\\user\\git\\pixi-project"
export PIXI_PROJECT_ROOT="D:\\home\\user\\git\\pixi-project"
export CONDA_ENV_SHLVL_2_PIXI_PROJECT_MANIFEST="D:\\home\\user\\git\\pixi-project\\pixi.toml"
export PIXI_PROJECT_MANIFEST="D:\\home\\user\\git\\pixi-project\\pixi.toml"
export CONDA_ENV_SHLVL_2_PIXI_PROJECT_NAME=pixi-project
export PIXI_PROJECT_NAME=pixi-project
export CONDA_ENV_SHLVL_2_PIXI_IN_SHELL=1
export PIXI_IN_SHELL=1
export CONDA_ENV_SHLVL_2_CONDA_DEFAULT_ENV=pixi-project
export CONDA_DEFAULT_ENV=pixi-project
export CONDA_ENV_SHLVL_2_PIXI_ENVIRONMENT_NAME=default
export PIXI_ENVIRONMENT_NAME=default
export CONDA_ENV_SHLVL_2_PIXI_ENVIRONMENT_PLATFORMS=win-64
export PIXI_ENVIRONMENT_PLATFORMS=win-64
export CONDA_ENV_SHLVL_2_PIXI_PROMPT='(pixi-project) '
export PIXI_PROMPT='(pixi-project) '

# shellcheck shell=bash
pixi() {
    local first_arg="${1-}"

    "${PIXI_EXE-}" "$@" || return $?

    case "${first_arg-}" in
    add | a | remove | rm | install | i)
        eval "$("$PIXI_EXE" shell-hook --change-ps1 false)"
        hash -r
        ;;
    esac || :

    return 0
}

export PS1="(pixi-project) ${PS1:-}"

Expected behavior

pixi shell working on fish in MSYS2.

Things work fine if I run set -gx PATH (string split ';' $Path | while read -l item; cygpath $item; end) to correct the PATH based on Path.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions