Skip to content

mamba run fails in non-TTY runners with "Undefined error: 0" #4165

@sghng

Description

@sghng

Summary

In non-interactive process runners (no TTY on stdin/stdout/stderr), mamba run fails immediately and prints Undefined error: 0 to stderr. The same command works in interactive shells (fish/zsh/bash). Detached mode (-d) succeeds in the same non-TTY runner, which suggests a stdio/attach handling issue in mamba run when no PTY is available.

Potentially related to #3344.

This is important because the use of AI agents is extensive nowadays. It would be immensely helpful to make Mamba agent-friendly.

Context

This shows up in AI agent tool runners (e.g., Zed, OpenCode), which execute commands without a TTY. The runner captures stdout/stderr programmatically; mamba run should still work, but it fails with the error above.

Reproduction (non-TTY)

  1. Run in a non-TTY context (stdio is not a TTY):

    • Verified in this runner by uv run python -c "import sys; print(sys.stdin.isatty(), sys.stdout.isatty(), sys.stderr.isatty())" -> False False False
  2. Command:
    mamba run -n ds python -c "print('hi')"

  3. Result:

    • stdout: empty
    • stderr: "Undefined error: 0"

Capturing output with redirects:

   mamba run -n ds python -c "print('hi')" 1> /tmp/mamba_stdout.txt 2> /tmp/mamba_stderr.txt
   /tmp/mamba_stdout.txt => empty
   /tmp/mamba_stderr.txt =>
     Undefined error: 0

Expected

mamba run should execute the target process and write to stdout normally, even without a TTY.

Actual

mamba run immediately fails with stderr: Undefined error: 0.

What works

  • Detached mode succeeds in the same non-TTY runner:
    mamba run -n ds -d python -c "print('hi')"
    Output: "Running wrapped script exec python -c print('hi') in the background"

What does NOT work

  • Default attach behavior:
    mamba run -n ds python -c "print('hi')"
    -> Undefined error: 0

  • Explicit attach variants:
    mamba run -n ds -a "" python -c "print('hi')" -> Undefined error: 0
    mamba run -n ds -a stdin python -c "print('hi')" -> Undefined error: 0
    mamba run -n ds -a stderr python -c "print('hi')"-> Undefined error: 0
    mamba run -n ds -a stdout -a stderr python -c "print('hi')" -> Undefined error: 0

Environment

  • macOS 26.3 (arm64)
  • Kernel: Darwin 25.3.0
  • mamba 2.5.0 / libmamba 2.5.0
  • MAMBA_ROOT_PREFIX=/Users/sghuang/mamba
  • env name: ds (exists and works interactively)

Command outputs

  uname -a:
    Darwin samuel-mbp 25.3.0 Darwin Kernel Version 25.3.0: Wed Jan 28 20:54:22 PST 2026; root:xnu-12377.81.4~5/RELEASE_ARM64_T6030 arm64

  sw_vers:
    ProductName: macOS
    ProductVersion: 26.3
    BuildVersion: 25D125

mamba info:
  libmamba version : 2.5.0
  mamba version    : 2.5.0
  envs directories : /Users/sghuang/mamba/envs
  base environment : /Users/sghuang/mamba
  platform         : osx-arm64

Non-TTY verification:

  uv run python -c "import sys; print('isatty',sys.stdin.isatty(),sys.stdout.isatty(),sys.stderr.isatty())"
  -> isatty False False False

Hypothesis

mamba run appears to require a PTY or fails when attaching to stdio in non-interactive environments. Detached mode avoids stdio attach and therefore succeeds. This breaks compatibility with non-interactive command runners used by AI agents and some CI contexts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions