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

app starts from Terminal but not Finder #220

Open
franzinc opened this issue Jan 6, 2022 · 5 comments
Open

app starts from Terminal but not Finder #220

franzinc opened this issue Jan 6, 2022 · 5 comments

Comments

@franzinc
Copy link

franzinc commented Jan 6, 2022

This took me a long time to figure out, so I'm filing this so others know about it.

The script that I've used for a long time has always had this near the top:

exec > "$HOME/.app.log"
exec 2>&1
set -x
# lots more stuff after the above 2 exec's will now be recorded in $HOME/.app.log

Turns out, if I include those, the app starts fine from Terminal but not from Finder. It used to work starting from Finder, but at some point in the last few months it just stopped working. I'm using /bin/zsh as the SHELL, but I believe it fails with /bin/bash, too.

I suspect this is due to security issues in macOS, but I have no idea.

@artcs
Copy link

artcs commented Jan 9, 2022

Most probably $HOME isn't set, so you're trying to write to /.app.log in the root directory.
You could try "~/.app.log" instead. If you need more environment settings, try setting -l als interpreter arg (see here, should work with zsh the same way), so the shell acts like being invoked as a login shell.

@artcs
Copy link

artcs commented Jan 9, 2022

From zsh manpage:

HOME <S>
              The  default argument for the cd command.  This is not set auto-
              matically by the shell in sh, ksh or csh emulation […]

Do you use /bin/zsh explicitly (under Script Type) or is zsh invoked with /bin/sh?

@franzinc
Copy link
Author

franzinc commented Jan 9, 2022

I'm 100% sure this is not the problem because the file in $HOME had stuff in it. I had set -x just after the exec's and the last command, that started the app, was in the log file.

I used -p /bin/zsh to the command line version.

@artcs
Copy link

artcs commented Jan 9, 2022

Ok, was just a blind guess. FWIW: Your snippet works fine here on MacOS 10.13 with sh (bash) and zsh from Finder (created from the app, I don't use the command line version), so I cannot reproduce your issue.
Good luck.

@franzinc
Copy link
Author

I'll play around and see if I can make a reproducible test case.

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