Skip to content

react_native_pods_utils/script_phases.sh error() executes the message as a command instead of logging it #56955

@fallintoplace

Description

@fallintoplace

Description

packages/react-native/scripts/react_native_pods_utils/script_phases.sh defines:

error () {
    echo "$1"
    "[Codegen] $1" >> "${SCRIPT_OUTPUT_FILE_0}" 2>&1
    exit 1
}

The second line does not append a log message. It attempts to execute a command whose name is the formatted error string.

In practice this means:

  • the helper can fail with command not found before reaching the intended exit 1 when set -e is active
  • SCRIPT_OUTPUT_FILE_0 receives the shell error instead of the intended [Codegen] ... log line
  • multi-part messages are truncated because the function only prints $1

This looks like a regression introduced when the script was extracted into script_phases.sh in commit 1dbbeb4462e67ffecf0a4634cf3eb039886e21a2 (Move script_phases script out of ruby file.). The earlier inline implementation in scripts/react_native_pods.rb wrote the message directly to SCRIPT_OUTPUT_FILE_0 and did not attempt to execute it.

Steps to reproduce

  1. Check the current main branch source.
  2. Run this standalone shell repro:
bash -lc 'set -e; rm -f /tmp/rn-codegen-test.log; f(){ echo "$1"; "[Codegen] $1" >> /tmp/rn-codegen-test.log 2>&1; echo after; }; f hello'
  1. Observe that the shell exits with status 127 before echo after runs.
  2. Inspect /tmp/rn-codegen-test.log and observe that it contains a shell error (command not found) rather than the intended [Codegen] hello message.

React Native Version

main at b32a6c9e9db (observed on May 24, 2026)

Affected Platforms

  • Runtime - iOS
  • Build - MacOS

Output of npx @react-native-community/cli info

N/A. This is a source-level bug in a repository shell script and can be reproduced with the standalone shell command above.

Stacktrace or Logs

Example repro output:

hello

The shell exits with status 127, and /tmp/rn-codegen-test.log contains:

bash: [Codegen] hello: command not found

MANDATORY Reproducer

The standalone shell repro above is minimal and does not require a separate sample app or external library.

Screenshots and Videos

N/A

Suggested fix

error () {
    message="$*"
    echo "$message"
    echo "[Codegen] $message" >> "${SCRIPT_OUTPUT_FILE_0}" 2>&1
    exit 1
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: Author FeedbackNeeds: ReproThis issue could be improved with a clear list of steps to reproduce the issue.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions