Fix silent halt in personal packages layer, and make failures visible - #2
Open
davidjalbers wants to merge 2 commits into
Open
Fix silent halt in personal packages layer, and make failures visible#2davidjalbers wants to merge 2 commits into
davidjalbers wants to merge 2 commits into
Conversation
`apt_from_file` ended with `[[ ${#extrepo[@]} -gt 0 ]] && apt_extrepo …`.
When a manifest has no `extrepo` lines the test is false, the `&&` short-
circuits, and the function returns 1. As the last command in the function
under `set -e`, that aborted the entire script right after the apt install
output — with no error message, so `ok "personal packages installed"` and
the chezmoi layer never ran.
Replace the guards with `if` blocks in `apt_from_file`, and fix the same
latent pattern in `layer_packages` for the macOS formulae/casks arrays.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014hnxvLH9J3K4PjhgPLyWb5
The personal-packages halt was one instance of a general problem: this script could stop or skip work without saying anything. Address the class. - ERR trap reports the aborting line number. The original bug produced no output at all; it would have been a one-line diagnosis with this. - Download-then-run the Homebrew and chezmoi installers. `bash -c "$(curl …)"` discards curl's exit status, so a failed download ran an empty script and reported success — "dotfiles applied" with no chezmoi installed. - fetch() names the URL when a manifest download fails, instead of curl exiting silently under set -e. - validate_config() runs before any layer, so an unedited MANUAL EDIT section fails in seconds rather than after a full package install. - Verify brew is actually present before eval-ing its shellenv. Also: - Register temp files and remove them from an EXIT trap, so an aborted layer no longer leaks them. - Run `apt-get update` once and re-arm it only when extrepo changes the sources: 4 updates down to 2 on a full Debian run. - Use `id -un` rather than $USER, which is not exported by every shell and would crash under `set -u`. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014hnxvLH9J3K4PjhgPLyWb5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The reported bug
The script stopped in the personal packages layer:
personal packages installedwas never logged and the chezmoi layer never ran, with the apt output from the previous step as the last thing on screen.apt_from_fileended with:For an
apt.txtwith noextrepo …lines the array is empty, the test is false, and the&&short-circuits. A short-circuitedtest && cmdhas exit status 1, and it was the last command in the function — soapt_from_filereturned 1 andset -eaborted the whole script. No message, nodie, exit code 1. Everything had actually installed correctly; only the reporting was missing.Replaced with
ifblocks, plus the same latent pattern inlayer_packageswhere an emptiedDEV_CORE_CASKS/DEV_CORE_FORMULAEwould have died the same way.Making the class of bug visible
That failure was invisible, so the rest of the change targets that rather than just the one line.
bash -c "$(curl …)"discards curl's exit status, so a failed download ran an empty script and reported success. This surfaced during testing: with the installer unreachable, the script printed✓ dotfiles appliedand exited 0 having installed nothing.fetch()names the URL when a manifest download fails, instead of curl exiting silently underset -e.validate_config()runs before any layer, so an unedited MANUAL EDIT section fails in seconds instead of after a full package install.Tidying
EXITtrap, so an aborted layer no longer leaks them.apt-get updateruns once and is re-armed only when extrepo actually changes the sources — 4 updates down to 2 on a full Debian run.id -uninstead of$USER, which is not exported by every shell and would crash underset -u.Testing
Ran the full script against stubbed
sudo/apt-get/extrepo/curl/chshon a simulated Debian:apt.txtwith no extrepo lines (the reported bug)apt.txtwith only extrepo lines (mirror case)bash -nclean. shellcheck was not available in this environment.Generated by Claude Code