Skip to main content
July 7, 2022
Question

Can't op run a sourced bash function

  • July 7, 2022
  • 3 replies
  • 448 views

$ 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:https://1password.community/search?Search=op%20run%20file%20not%20found

3 replies

July 11, 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:

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

July 12, 2022

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

July 13, 2022

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

Best,
Horia