Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Launchctl "command not found: bear" #3

Open
usizu opened this issue Dec 20, 2020 · 3 comments
Open

Launchctl "command not found: bear" #3

usizu opened this issue Dec 20, 2020 · 3 comments

Comments

@usizu
Copy link

usizu commented Dec 20, 2020

Hi,

I've made a shell script that uses Bear CLI to make custom journal entries for me, and I want to run these daily with launchctl. The script works when I run it from terminal, but when I run it with launchctl I get errors: "command not found: bear" on the lines that execute the Bear CLI commands.

It seems launchctl doesn't have permission to run Bear CLI?

The two lines in question:

noteId=$(bear create " " -n=${printDate})
noteNew=$(bear add-text ${journal} --id=${noteId} --mode=replace_all)

I tried giving Bear CLI Full Disk Acccess in System Preferences -> Security & Privacy but that didn't help. I'm quite new to scripting, terminal and launchd. Thanks for any tips.

@usizu
Copy link
Author

usizu commented Dec 20, 2020

I've seen it suggested in other threads (https://superuser.com/questions/1044228/unable-to-load-script-via-launchctl-command-not-found#1044245) that "command not found" is because if a script is run by launchctl then it needs the absolute path. In the case of Bear CLI what would that be? I tried /Users/myuser/path-to-Bear-CLI-project/bin/run but that gives the error "env: node: No such file or directory", and I tried pointing /usr/local/lib/node_modules/@sloansparger/bear and /bear/bin/ but those gave me a permissions error, even when running launchctl with sudo.

@usizu
Copy link
Author

usizu commented Dec 20, 2020

Ok it turns out adding export PATH=$PATH:/usr/local/bin to my script was able to fix the paths. Hopefully that will be useful to anyone else trying to get this to work with launchctl.

@sloansparger
Copy link
Owner

sloansparger commented Dec 21, 2020

@usizu thanks for walking through the problem and solution. Like you said, this isn’t the first time someone has hit this issue, so I’ll go ahead and add it to the README so others benefit!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants