Postinstall script - sh: command not found

CDC2021
New Contributor II

Having issue with postinstall script that I cannot seem to spot. We have done this 100 times, but all of the sudden this package, recreated several times, fails. I have removed and added all spaces and line returns to get rid of anything odd.

The package extracts files to a folder then the postinstall script executes MMC_Install.sh to perform the install. I know MMC_Install.sh is sound as I have tested outside capture. The issue is that postinstall fails to launch the sh command. I found the below in console install.log:

2021-12-22 10:29:04-06 macos-10 package_script_service[533]: PackageKit: Executing script "postinstall" in /tmp/PKInstallSandbox.0LaYFY/Scripts/macdocusignedit-2.1.0.0-r1.9PgfhO

2021-12-22 10:29:04-06 macos-10 package_script_service[533]: Set responsibility to pid: 525, responsible_path: /System/Library/CoreServices/Installer.app/Contents/MacOS/Installer

2021-12-22 10:29:05-06 macos-10 package_script_service[533]: ./postinstall: /tmp/PKInstallSandbox.0LaYFY/Scripts/macdocusignedit-2.1.0.0-r1.9PgfhO/postinstall: line 8:

                sh: command not found

2021-12-22 10:29:05-06 macos-10 package_script_service[533]: Responsibility set back to self.

Any advice would be welcome.

Screen Shot 2021-12-22 at 12.13.28 PM.pngScreen Shot 2021-12-22 at 12.12.17 PM.png

1 ACCEPTED SOLUTION

mm2270
Legendary Contributor III

Just for kicks, what happens if you change the shell interpreter for the postinstall script to something else, like /bin/bash or /bin/zsh ? Same error? Also, are you still seeing that same sh: command not found error when it does not have either /bin/sh or sh at the start of line 8?

As for the exclamation mark always showing up in those postinstall scripts, something doesn't smell right to me. That should go away and be replaced by a Terminal icon in Composer when it sees that the script has validated properly, like this:

Screen Shot 2021-12-22 at 4.01.59 PM.png

If you're still seeing that bubble exclamation, I'm thinking something just isn't right with the script, and Composer knows it. It's just figuring out what's wrong that's the hard part. From your screenshot, it looks perfectly valid. Open and closing straight quotes, no weird characters from what I can see.

Maybe delete the postinstall script and start over, and don't copy in a path to the script. Type it into the Composer script editor and see if anything is different. Maybe there's some hidden character in there it's not liking.

View solution in original post

13 REPLIES 13

dwbergstrom
New Contributor III

Does the absolute path for sh work by any chance?  

 

/bin/sh "/Library/..."

 

CDC2021
New Contributor II

Will give a try. Thanks.

CDC2021
New Contributor II

Same sh: command not found when using full path. 

Actual text is:

/bin/sh: No such file or directory

wow!

mm2270
Legendary Contributor III

Just for kicks, what happens if you change the shell interpreter for the postinstall script to something else, like /bin/bash or /bin/zsh ? Same error? Also, are you still seeing that same sh: command not found error when it does not have either /bin/sh or sh at the start of line 8?

As for the exclamation mark always showing up in those postinstall scripts, something doesn't smell right to me. That should go away and be replaced by a Terminal icon in Composer when it sees that the script has validated properly, like this:

Screen Shot 2021-12-22 at 4.01.59 PM.png

If you're still seeing that bubble exclamation, I'm thinking something just isn't right with the script, and Composer knows it. It's just figuring out what's wrong that's the hard part. From your screenshot, it looks perfectly valid. Open and closing straight quotes, no weird characters from what I can see.

Maybe delete the postinstall script and start over, and don't copy in a path to the script. Type it into the Composer script editor and see if anything is different. Maybe there's some hidden character in there it's not liking.

CDC2021
New Contributor II

I tried both interpreters and neither helped. 

I then did as you suggested, deleted and created a new script by adding only the typed command to default script. It did change to the exclamation again (as all of them appear to) but this time it worked! I am not sure why, I replaced the spaces and quotes in that line many times. Only thing I was pasting was the path, verifying it with Finder>Go. I had even started with a fresh default script several times before.

No idea why we always see that exclamation.

Thank you so much for a sanity check. Been messing with this for 2 days and it did not make any sense at all.

 

 

mm2270
Legendary Contributor III

That's pretty strange that the exclamation mark remains, but maybe it's just a bug in the version of Composer you have. The whole point of that showing up is to alert you to a problem with the script, so it seems like its a false alarm that won't turn off!

Anyway, I'm glad recreating the script worked. I've run into issues like this that seem to defy all logic, and sometimes just starting over is the trick for whatever dumb reason.

mm2270
Legendary Contributor III

Remove the "sh" from the command in the script. You don't need that, as long as the MMC_Install.sh script is executable.

CDC2021
New Contributor II

I tried that earlier and no go.

mm2270
Legendary Contributor III

And what error did you get when removing the sh from the start? Same one or a different error?

As long as the script has the executable bit set (which from your screenshot it seems like it does), and it's a valid script, AND the script is being placed into that location shown in your post install script, calling it in the post install script like that should work.

Is the MMC_Install.sh script from the vendor?

Edit: Also, I don't know at what point you took the screenshot of the Composer source view, but I can see that your postinstall script has the exclamation mark next to it, which means Composer is seeing some issue with the script. Did you resolve that already or is it still showing that talk bubble with the exclamation mark in it?

CDC2021
New Contributor II

I try it again as I did not look at install log the first time. 

MMC_Install.sh is in house. I know it is valid because I can run it from the installation folder and it performs the install with the logging. It just never runs from the PKG postinstall in this one package.

Even the packages that work, have that exclamation bubble. I always thought it was from the default variables added and not set when compile evaluated. If I choose compile, I see Line 0 getcwd. I see the same thing when adding default script and nothing else then checking compile. Editing the default script at all changes it to the exclamation.

 

CDC2021
New Contributor II

Without sh in the command, the install.log shows 

/Library/MMC/Packages/MAC_DocuSign_Edit-2.1.0.0-R1/MMC_Install.sh: No Such file or directory

 

Very odd as it is definitely there. That part of the install is working.

 

mm2270
Legendary Contributor III

Interesting. So it's not seeing the script to even run, even though the main part of the package is dropping it into that path.

Honestly, I'm not really sure what the issue could be. You're certain you have the exact correct path input into the script? Can you make sure there is no hidden space at the end of the script name, or anything weird like that?

mariac
New Contributor

what are the permissions for MMC_Install.sh file? Are they set to 755 or 754? 755 - rwx-r-x-r-x. I have seen that error when the .sh script doesn't have the proper permissions.