Platypus icon indicating copy to clipboard operation
Platypus copied to clipboard

app starts from Terminal but not Finder

Open franzinc opened this issue 3 years ago • 5 comments

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.

franzinc avatar Jan 06 '22 21:01 franzinc

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 avatar Jan 09 '22 10:01 artcs

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?

artcs avatar Jan 09 '22 12:01 artcs

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.

franzinc avatar Jan 09 '22 22:01 franzinc

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.

artcs avatar Jan 09 '22 22:01 artcs

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

franzinc avatar Jan 10 '22 04:01 franzinc