Skip to content

ripgrep operation not permitted #4620

Closed

Description

@aehlke

What version of Codex is running?

0.42.0

Which model were you using?

No response

What platform is your computer?

No response

What steps can reproduce the bug?

I get this error when codex tries to use rg:

• Ran zsh -lc 'rg "tabSelection = .reader" -n'
  └ /opt/homebrew/Homebrew/Library/Homebrew/cmd/shellenv.sh: line 18: /bin/ps: Operation not permitted

Something in my environment must be breaking this. Please advise... not sure how to debug this.

What is the expected behavior?

No response

What do you see instead?

No response

Additional information

No response

Activity

  1. added
    bug
    on Oct 2, 2025
  2. tekumara commented on Oct 3, 2025

    @tekumara
    Contributor

    I see /bin/ps: Operation not permitted](shellenv.sh: line 18: /bin/ps: Operation not permitted) on any command, not just rg. NB: the command succeeds, but the model sees the error and comments on it.

    I think it's because shellenv.sh is in .zprofile:

    ❯ cat ~/.zprofile
    eval "$(/opt/homebrew/bin/brew shellenv)"
    

    And zsh runs inside the sandbox, which doesn't allow ps

  3. xab3r commented on Oct 4, 2025

    @xab3r

    I use GNU bash as the shell and have the same problem. This worked for me:

    # eval $(/opt/homebrew/bin/brew shellenv)
    eval $(/opt/homebrew/bin/brew shellenv bash)

    Steps to reproduce:

    $ codex
    ▌ run 'echo $PATH'
  4. added a commit that references this issue on Oct 4, 2025
  5. tekumara commented on Oct 4, 2025

    @tekumara
    Contributor

    Thanks @xab3r that avoids running /bin/ps here and worked for me!

  6. aehlke commented on Oct 10, 2025

    @aehlke
    Author

    I use GNU bash as the shell and have the same problem. This worked for me:

    Sorry I am a bit dumb - what do you do with this eval?

    edit: Oh, put it in zprofile

  7. skovtunenko commented on Oct 28, 2025

    @skovtunenko

    I use GNU bash as the shell and have the same problem. This worked for me:

    eval $(/opt/homebrew/bin/brew shellenv bash)

    Thank you @xab3r , this is working for me as well.
    My default shell is fish, but adding those instructions to .bash_profile solved a problem.

  8. songkeys commented on Nov 4, 2025

    @songkeys

    Alternatively, get the path of codex, for example:

    which codex
    /opt/homebrew/bin/codex

    On macOS, System Settings -> Privacy & Security -> Full Disk Access, select +, add the codex binary file:

    Image
  9. added
    tool-calls
    on Nov 14, 2025
  10. GringoDotDev commented on Nov 20, 2025

    @GringoDotDev

    I worked around this by replacing the existing shellenv eval with this in .zprofile:

    # Only run Homebrew shellenv in interactive shells,
    # and only if brew actually exists.
    if [[ $- == *i* ]] && [[ -x /opt/homebrew/bin/brew ]]; then
      eval "$(/opt/homebrew/bin/brew shellenv)"
    fi
    

    So far seems to be working for me.

  11. ishibashi-futos commented on Nov 21, 2025

    @ishibashi-futos

    I worked around this by replacing the existing shellenv eval with this in .zprofile:

    # Only run Homebrew shellenv in interactive shells,
    # and only if brew actually exists.
    if [[ $- == *i* ]] && [[ -x /opt/homebrew/bin/brew ]]; then
      eval "$(/opt/homebrew/bin/brew shellenv)"
    fi
    

    So far seems to be working for me.

    @GringoDotDev
    Thank you. I was saved by your content.

  12. iagooar commented on Nov 30, 2025

    @iagooar

    I think this is something codex developers should fix, any workaround in this area is just a patch.

  13. vaspike commented on Dec 3, 2025

    @vaspike

    Alternatively, get the path of codex, for example:

    which codex
    /opt/homebrew/bin/codex
    On macOS, System Settings -> Privacy & Security -> Full Disk Access, select +, add the codex binary file:

    Image

    In fact, I was unable to add it successfully on my macOS version(26.1).

  14. unmarked Permissions issues continue #8104 as a duplicate of this issue on Dec 16, 2025
  15. fliingelephant commented on Dec 18, 2025

    @fliingelephant

    Alternatively, get the path of codex, for example:
    which codex
    /opt/homebrew/bin/codex
    On macOS, System Settings -> Privacy & Security -> Full Disk Access, select +, add the codex binary file:
    Image

    In fact, I was unable to add it successfully on my macOS version(26.1).

    Same for macOS 26.2

  16. slaterx commented on Dec 24, 2025

    @slaterx

    I was facing the same on macOS 26.2 with Codex installed from Node. I then removed it completely and installed 0.77 using brew. Then I got a prompt asking permission to run the app I downloaded from the internet. After saying yes, stuff started to work again.

  17. lgh06 commented on Jan 6, 2026

    @lgh06

    same bug in codex-cli 0.77.0
    installed from npm

  18. priyathamkat commented on Jan 7, 2026

    @priyathamkat

    I see this bug too on codex 0.79.0

  19. etraut-openai commented on Jan 28, 2026

    @etraut-openai
    Contributor

    Codex runs commands via a login shell (zsh -lc), which executes ~/.zprofile. If that file runs brew shellenv, Homebrew tries to call /bin/ps to detect the parent shell, and macOS Seatbelt blocks that call, producing the “Operation not permitted” message on stderr.

    As a potential workaround, enable the shell_snapshot experimental feature using the /experimental slash command. Let us know if that resolves the problem.

  20. etraut-openai commented on Mar 29, 2026

    @etraut-openai
    Contributor

    This bug hasn't been upvoted or commented in in two months. I suspect it's no longer an issue. I'm going to close. If you're still seeing this, please use /feedback to open a new bug report and include your thread ID.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugtool-calls

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions