grahampugh / erase-install

A script that automates downloading macOS installers, and optionally erasing or upgrading macOS in a single process. Watch the video!
https://grahamrpugh.com/2023/05/14/macaduk-presentation-eraseinstall.html
Apache License 2.0
836 stars 131 forks source link

Exit with error code 42 #398

Closed randp82 closed 1 year ago

randp82 commented 1 year ago

I have set up the script to update Mac OS from 12.6.6 to 13.4. But every time it exits with error code 42 and the script ends.

Script result: [erase-install-launcher] Starting script "/Library/Management/erase-install/erase-install.sh" --pkg --os=13 --overwrite --reinstall --update --dialog-on-download --no-fs --min-drive-space=30 --current-user --check-power --power-wait-limit 3600

I tested it out on Apple Silicon Mac and both end up with the same error code 42. The script basically downloads the new OS and as soon as it tries to install OS downloaded OS installer in the Application folder.

Note: I'm using the latest version of the script v29.1

Here is the short version of the logs after it downloads the Installer:

2023-06-07 12:55:00 [run_mist] InstallAssistant-13.4-22F2073.pkg downloaded to /Library/Management/erase-install. 2023-06-07 12:55:00 [check_free_space] OK - 412 GB free/purgeable disk space detected 2023-06-07 12:55:00 [unpack_pkg_to_applications_folder] Unpacking /Library/Management/erase-install/InstallAssistant-13.4-22F2073.pkg into /Applications folder installer: Package name is InstallAssistant-13.4-22F2073 installer: Upgrading at base path / installer: The upgrade was successful. 2023-06-07 12:55:04 [unpack_pkg_to_applications_folder] Deleting /Library/Management/erase-install/InstallAssistant-13.4-22F2073.pkg 2023-06-07 12:55:04 [erase-install] WARNING! Running /Applications/Install macOS Ventura.app with reinstall option 2023-06-07 12:55:04 [erase-install] Sending quit message to dialog log (/var/tmp/dialog.Ro4) 2023-06-07 12:55:04 [get_default_dialog_args] Invoking utility dialog 2023-06-07 12:55:05 [launch_startosinstall] Launching startosinstall 2023-06-07 12:55:05 [erase-install] Sending password to startosinstall Error: The update cannot be installed on this computer. By using the agreetolicense option, you are agreeing that you have run this tool with the license only option and have read and agreed to the terms. If you do not agree, press CTRL-C and cancel this process immediately. [erase-install] Timeout reached for PID 3065! 2023-06-07 13:55:05 [erase-install] Reached end of script. Exit with error 42. 2023-06-07 13:55:05 [erase-install] attempting to terminate the 'caffeinate' process - Termination message indicates success 2023-06-07 13:55:05 [finish] sending quit message to dialog (/var/tmp/dialog.Ro4) 2023-06-07 13:55:05 [finish] Script exit code: 42 [erase-install-launcher] Exit (42)

Can you help me fix this? log.txt

grahampugh commented 1 year ago

Please update to v29.2 and retry.

whenbearsreign commented 1 year ago

Sorry to comment on an old threat, but I am having the exact same error. I have updated to v29.2 after initially receiving this error on v29.1.

These are the arguments I use

/Library/Management/erase-install/erase-install.sh --force-curl --fullscreen --reinstall --version=$VERSION --current-user  --overwrite  --depnotify --fs --cleanup-after-us --power-wait-limit 180 --postinstall-command "jamf recon"

($VERSION comes from the SoftwareUpdate Plist to put the recommended version in the argument.)

grahampugh commented 1 year ago

@whenbearsreign please post your logs. As I've said a few times above, the error code can be caused by multiple errors which should be shown on the log.

A few other comments on your command:

No reason to use --version when you're feeding in the latest version from softwareupdate. Remove --version completely and let erase-install do the logic for you (the default is the latest compatible version).

Also there's no --depnotify or --current-user in 29.2. Remove them. --fullscreeen is not a valid option either (and you've also supplied --fs anyway).

whenbearsreign commented 1 year ago

Thanks @grahampugh it it working now. I realized that the DP was out of sync so it looks like it still used 29.1 on the last run that failed. I had another attempt and it ran smoothly. I will be making those adjustments for sure. Looking at the arguments again, I'm not sure if I need --force-curl either because I am installing the package before running the script.

grahampugh commented 1 year ago

Yep, --force-curl is not required for anyone using the package installer or using >= v28.0. That was only really to pull down installinstallmacos.py which isn't used any more.