Can't op run a sourced bash function

jhellma1
jhellma1
Community Member

$ 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

Comments

  • Horia.Culea_1P
    edited July 2022

    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:

    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

  • jhellma1
    jhellma1
    Community Member

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

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

    Best,
    Horia

This discussion has been closed.