Repository navigation
fix(ci): scope the gem cache restore to the Nix environment - #54
Merged
Merged
Conversation
Native gem extensions (syslog, fiddle, bigdecimal) link against the exact Nix store path of the libruby and libffi they were built with, and Ruby refuses to load an extension linked to a different libruby. The restore prefix gems-<os>- matched any earlier bundle, so a nixpkgs bump that changed the Ruby build restored extensions compiled for the old one. require "syslog" then failed, and Puppet aborted with "Cannot determine basic system flavour". Key the cache on the dev-shell hash (the Nix files and flake.lock) and Gemfile.lock, and restore only within the same dev-shell hash. A flake change now always starts a fresh bundle; a Gemfile.lock-only change still reuses the last bundle built for the same environment.
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.
Problem
How CI gets its Ruby gems
flake.lockpins the exact nixpkgs revision, and with it the exact Ruby build.Gemfile.lockintovendor/bundle.vendor/bundlewithactions/cache.What goes wrong
flake.lockandGemfile.lock, so a nixpkgs bump does produce a new key. On a key miss, though, the fallbackrestore-keys: gems-<os>-matches any earlier bundle, including one built under a different Ruby.bundle installsees every gem as installed and rebuilds nothing.Evidence
6fcc160to1f607aain the nix group across 1 directory #52 (nixpkgs bump, Ruby 3.3.10 to 3.3.13) fails both Puppet jobs withCannot determine basic system flavour.syslogextension did not load. Puppet 8.10 needs syslog to detect a POSIX system.syslogbuild aslinked to incompatible …libruby-3.3.10.dylib.syslog.so, and theirbundled_gems.rbare identical.Fix
Both gem cache steps now key on
gems-<os>-<hash of the Nix files and flake.lock>-<hash of Gemfile.lock>and restore only within the same Nix hash:Gemfile.lock-only change still reuses the last bundle from the same environment.Verification
syslogwas rebuilt, and all jobs pass.6fcc160to1f607aain the nix group across 1 directory #52: its gem cache step should miss, and both Puppet jobs should pass.Appendix
CI runs of #52
0b09b2c(run, 2026-10-21)gems-Linux-b0bcc816…(from main)gems-Linux-2c06d127…599114c(run, 2026-10-28)gems-Linux-2c06d127…From the failing Unit tests job:
Why syslog stops Puppet
lib/puppet/feature/base.rbin Puppet 8.10.0 definesposixas!Etc.getpwuid(0).nil? && Puppet.features.syslog?and raisesCannot determine basic system flavourwhen neitherposixnormicrosoft_windowsholds. The Gemfile pinssyslog0.4.0, a C extension.Local reproduction (aarch64-darwin)
Loading the extension fails with
linked to incompatible …/libruby-3.3.10.dylib. Afterbundle pristinerebuilds it,just checkpasses.