Signing back into the Community for the first time? You'll need to reset your password to access your account.  Find out more.

Forum Discussion

Former Member's avatar
Former Member
3 years ago

Can't op run a sourced bash function

$ op run --env-file=$HOME/.config/op/aws/$AWS_PROFILE -- jhdev docker ecr-login
[ERROR] 2022/07/07 13:32:00 error while starting process: exec: "jhdev": executable file not found in $PATH

Any fix or workaround for this I'm missing?


1Password Version: 8.7.3
Extension Version: n/a
OS Version: macOS 12.4
Browser:_ n/a
Referrer: forum-search:op run file not found

  • Former Member's avatar
    Former Member

    Hey @jhellma1 ,

    Thank you for reaching out to us!
    I think there are a couple of issues here:
    * the library that we use for interpreting and running the commands passed to op run doesn't delegate calling commands to a shell, but calls the commands itself, hence it doesn't have the context of functions/aliases defined in the calling shell's profile
    * even if they were to do op run -- $SHELL -c <their command> (which circumvents the problem above) , shell functions are not exported to subshells, since, in general, they aren't meant to be used like this

    However, in bash, there's a workaround for this, since functions can actually be exported.
    Here's a toy example of how this would work:

    bash
    function myFunction() { echo "hey there"; }
    export -f myFunction
    op run -- /bin/bash -c myFunction

    Let us know if this helps. Looking forward to hearing from you!

    Best,
    Horia

  • Former Member's avatar
    Former Member

    Hello Horia, this was very helpful and I'm all good now, thanks!

  • Former Member's avatar
    Former Member

    Glad to have sorted it out! Let us know if we can be of help with anything else.

    Best,
    Horia