Skip to content

pixi run double-escapes backslashes in command arguments since v0.53.0 #5054

@hb1915

Description

@hb1915

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

Commands I ran and their output:

# Create a simple test
JSON='{"a": "b\"c"}'

# Direct execution - works correctly
python3 -c "import sys, json; print(repr(sys.argv[1])); json.loads(sys.argv[1])" "$JSON"
# Output: '{"a": "b\\"c"}'
# ✓ Valid JSON

# Via pixi run - fails
pixi run python -c "import sys, json; print(repr(sys.argv[1])); json.loads(sys.argv[1])" "$JSON"
# Output: '{"a": "b\\\\"c"}'
# ✗ json.decoder.JSONDecodeError: Expecting ',' delimiter

pixi.toml/pyproject.toml file that reproduces my issue:

[workspace]
authors = ["'Harry Brady' <x>"]
channels = ["condaforge"]
name = "pixi-escape-repro"
platforms = ["linux-64"]
version = "0.1.0"

[dependencies]
python = ">=3.14.0,<3.15"

pixi info output:

System
------------
       Pixi version: 0.59.0
           Platform: linux-64
   Virtual packages: __unix=0=0
                   : __linux=4.18.0=0
                   : __glibc=2.28=0
                   : __archspec=1=skylake_avx512
          Cache dir: /home/hbrady/.cache/rattler/cache
       Auth storage: /home/hbrady/.config/pixi/credentials.json
   Config locations: /home/hbrady/.config/pixi/config.toml

Other files (e.g. script files, source files, etc.):

Issue description

When passing command-line arguments containing backslash escape sequences (like \" or \n) through pixi run, the backslashes are incorrectly double-escaped before being passed to the subprocess. This breaks JSON parsing and other use cases that rely on properly escaped strings.

When I tested downgrading versions, the version at which this begins to occur is 0.53.0

Expected behavior

JSON='{"a": "b\"c"}'

pixi run python -c "import sys, json; print(repr(sys.argv[1])); json.loads(sys.argv[1])" "$JSON"
# Output: '{"a": "b\\"c"}'
# ✓ Valid JSON

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions