Skip to content

fix(installer): install.sh prints color codes only on a terminal and honors NO_COLOR - #4429

Merged
Daniel Meppiel (danielmeppiel) merged 3 commits into
mainfrom
bug-sweep/p4308
Nov 21, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 3 commits into
mainfrom
bug-sweep/p4308

Conversation

@danielmeppiel

Copy link
Copy Markdown
Collaborator

Description

install.sh set its color variables (RED, GREEN, BLUE, YELLOW, NC) unconditionally, so its output carried ANSI escape sequences even when stdout was not a terminal. apm self-update passes the installer output through, so piped or captured self-update output had escape characters too (lifecycle output invariant I6).

Colors are now set only when stdout is a terminal ([ -t 1 ]) and NO_COLOR is unset; otherwise the variables are empty and the output is plain text. scripts/install.sh prints no colors and is unchanged.

Strict cells flipped

Issue and approved scope

Issue: Fixes #4308 (scope record: #4308 (comment))

Human scope-approval comment: the scope record above.

Does this PR complete the issue, or what remains? It completes #4308.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally

  • All existing tests pass

  • Added tests for new functionality (if applicable)

  • Red before: pytest -n 0 tests/unit/test_unix_installer_checksums.py -k piped (new test_piped_output_has_no_color_codes, direct and apm self-update invocations, under bash and sh) failed on main. The output began with \x1b[0;34m.

  • Green after: pytest tests/unit/test_unix_installer_checksums.py passed (106 passed).

  • Self-update: with the cell removed, APM_E2E_TESTS=1 pytest -n 0 tests/integration/test_self_update_release_lifecycle.py passed (8 passed; the 2 fish variants are skipped because fish is not installed). The zsh variants of test_self_update_with_real_installer_preserves_shell_setup_state run the real installer under the I6 oracle.

  • Shell syntax: bash -n install.sh and sh -n install.sh passed.

  • Lint: uvx [email protected] check and format --check on the changed Python files passed.

  • Ledger: tests/quality/test_lifecycle_bug_ledger.py passed.

Changelog

  • One line in one section under ## [Unreleased] in CHANGELOG.md
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

  • N/A -- this PR does not change OpenAPM-observable behaviour.

…honors NO_COLOR

install.sh set its color variables unconditionally, so piped installer
output and `apm self-update` output carried escape characters. Colors now
need `[ -t 1 ]` and an unset NO_COLOR. The STRICT output cell
self-update-installer-color-codes is removed.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
@danielmeppiel Daniel Meppiel (danielmeppiel) added this to the 0.37.0 milestone Nov 20, 2026
Copilot AI balanced review requested due to automatic review settings November 20, 2026 17:11
Co-authored-by: copilot-swe-agent[bot] <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The installer still emits ANSI escapes when NO_COLOR is set to an empty value, violating the stated contract and requiring a presence check with terminal-backed tests.

1 open issue
What changed in this PR

This PR addresses #4308 by making the Unix installer’s color output terminal-aware, preventing ANSI escapes from leaking into piped or captured apm self-update output.

Changes:

  • Gates installer colors on terminal stdout and NO_COLOR.
  • Adds captured-output regression tests for direct installation and self-update under bash and sh.
  • Removes the known lifecycle output exception and records the fix in the bug ledger and changelog.
File Description
tests/​utils/​lifecycle_evidence.py Removes the installer color-code exception from the output invariant checks.
tests/​unit/​test_unix_installer_checksums.py Adds regression coverage for escape-free captured output.
tests/​fixtures/​lifecycle_bug_ledger.json Links issue #4308 to its regression tests.
install.sh Conditionally initializes color variables based on stdout and NO_COLOR.
CHANGELOG.md Documents the installer and self-update output fix.

Review effort: Balanced

Comment thread install.sh
YELLOW=$(printf '\033[1;33m')
NC=$(printf '\033[0m') # No Color
# Colors for output: only on a terminal, and never when NO_COLOR is set.
if [ -t 1 ] && [ -z "${NO_COLOR:-}" ]; then
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
… on a terminal and honors NO_COLOR

Co-authored-by: Copilot App <[email protected]>

# Conflicts:
#	tests/fixtures/lifecycle_bug_ledger.json
#	tests/utils/lifecycle_evidence.py
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 392356e into main Nov 21, 2026
37 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the bug-sweep/p4308 branch November 21, 2026 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

install.sh emits ANSI color codes when stdout is not a terminal

2 participants