Skip to content

fix: run apt-get update before every apt-get install#101

Merged
ramonskie merged 1 commit intomainfrom
fix-apt-get-update-before-install
Apr 14, 2026
Merged

fix: run apt-get update before every apt-get install#101
ramonskie merged 1 commit intomainfrom
fix-apt-get-update-before-install

Conversation

@ramonskie
Copy link
Copy Markdown
Contributor

Problem

Ubuntu point-release supersessions cause 404 errors when a Docker image's apt package index is stale. The immediate trigger was libgdk-pixbuf2.0-bin/libgdk-pixbuf-2.0-dev version .4 being superseded by .5 on the Ubuntu jammy mirrors — these are transitive dependencies pulled in by libmagickwand-dev/libmagickcore-dev during PHP builds:

Err:16 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libgdk-pixbuf2.0-bin amd64 2.42.8+dfsg-1ubuntu0.4
  404  Not Found
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
binary-builder: building php: php: apt install php_build: ... exit status 100

This can happen to any recipe that installs packages, not just PHP.

Fix

Move apt-get update inside APT.Install() so every install call automatically refreshes the package index before installing. No call-site changes are needed — all recipes (php, ruby, python, node, r, httpd, hwc, autoconf, compiler) benefit unconditionally.

func (a *APT) Install(ctx context.Context, packages ...string) error {
    if len(packages) == 0 {
        return nil
    }
    if err := a.Update(ctx); err != nil {
        return fmt.Errorf("apt-get update: %w", err)
    }
    // ...
}

Notes

  • AddPPA still does its own apt-get update after adding the repo (necessary to pick up the new PPA sources). This means GCC.Setup runs update 3 times on cflinuxfs4 — harmless.
  • InstallReinstall is unchanged (used only for downloading .deb files in the Python recipe; same stale-index risk applies but that path is less exposed).
  • All 16 test packages pass.

Ubuntu point-release supersessions (e.g. libgdk-pixbuf2.0 .4 → .5) cause
404 errors when the Docker image's package index is stale. The failure
surfaces as a build error during php_build apt install but can affect any
recipe that installs packages.

Move apt-get update inside APT.Install() so every install call refreshes
the index automatically. No call-site changes are needed — all recipes
(php, ruby, python, node, r, httpd, hwc, autoconf, compiler) benefit
unconditionally.

Update tests to expect the update+install two-call sequence.
Copy link
Copy Markdown
Contributor

@ivanovac ivanovac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@ramonskie ramonskie merged commit b043376 into main Apr 14, 2026
1 check passed
@ramonskie ramonskie deleted the fix-apt-get-update-before-install branch April 14, 2026 12:55
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

Successfully merging this pull request may close these issues.

2 participants