Skip to content

Fix dep resolution and --HEAD flag leak in jdx-package#21

Merged
jdx merged 1 commit intomainfrom
fix/jdx-package-dep-resolution
Mar 25, 2026
Merged

Fix dep resolution and --HEAD flag leak in jdx-package#21
jdx merged 1 commit intomainfrom
fix/jdx-package-dep-resolution

Conversation

@jdx
Copy link
Copy Markdown
Owner

@jdx jdx commented Mar 25, 2026

Summary

Two bugs in cmd/jdx-package.rb:

  1. glibc@2.17 included when YJIT is enabled: Dependency.expand includes glibc@2.17 and linux-headers@4.4 even when YJIT is enabled (the default). The formula conditionally declares these deps with if build.without? "yjit", but the dep resolver doesn't honor build options. This causes the build to fail when glibc@2.17's post-install localedef step errors out. Fix by pruning these deps when --without-yjit is not passed.

  2. --HEAD flag leaks across loop iterations: The flags array is defined before the args.named.each loop and --HEAD is appended inside the loop without being removed. When processing multiple formulae, --HEAD accumulates across iterations. Fix by using flags.dup per iteration.

Test plan

  • Verified fix aligns with formula intent (glibc@2.17 is conditional on build.without? "yjit")
  • Build jdx-ruby@3.4.7 with YJIT on Linux — should no longer pull in glibc@2.17
  • Build multiple formulae in one invocation — --HEAD should not leak

🤖 Generated with Claude Code


Note

Medium Risk
Moderate risk because it changes dependency pruning and build flags for bottle builds, which can affect build outputs and CI behavior, but it’s localized to cmd/jdx-package.rb.

Overview
Fixes jdx-package packaging to avoid state leaking across formula builds by duplicating per-formula flags so --HEAD is applied only for the current name.

Adjusts dependency expansion to explicitly prune glibc@* and linux-headers@4.4 when YJIT is enabled (i.e., --without-yjit is not set), preventing unintended deps from being built/installed during bottle creation.

Written by Cursor Bugbot for commit 428fead. This will update automatically on new commits. Configure here.

Two bugs in jdx-package.rb:

1. Dependency.expand includes glibc@2.17 and linux-headers@4.4 even
   when YJIT is enabled (the default). The formula conditionally declares
   these deps with `if build.without? "yjit"`, but the dep resolver
   doesn't honor build options. This causes the build to fail when
   glibc@2.17's post-install localedef step errors out. Fix by pruning
   these deps when --without-yjit is not passed.

2. The `flags` array is defined before the `args.named.each` loop and
   `--HEAD` is appended inside the loop without being removed. When
   processing multiple formulae, `--HEAD` accumulates across iterations.
   Fix by using `flags.dup` per iteration.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses two critical bugs within the jdx-package command that impacted the reliability of formula builds. It ensures that dependency resolution correctly respects build options, specifically for YJIT-enabled Ruby formulas, and prevents unintended flag persistence when processing multiple formulas. These changes improve the robustness and correctness of the packaging process.

Highlights

  • Dependency Resolution: Resolved an issue where glibc@2.17 and linux-headers@4.4 were incorrectly included as dependencies when YJIT was enabled, leading to build failures. The fix prunes these dependencies when --without-yjit is not passed.
  • Flag Handling: Fixed a bug where the --HEAD flag would accumulate across multiple formula iterations due to the flags array being reused. The flags array is now duplicated for each iteration to prevent this leakage.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the handling of installation flags in cmd/jdx-package.rb by making the --HEAD flag conditional per named argument. It also introduces a new dependency pruning rule to exclude glibc@ and linux-headers@4.4 when YJIT is enabled. A suggestion was made to improve readability and performance by hoisting the !args.without_yjit? check out of the dependency expansion loop.

deps = Dependency.expand(Formula[name], cache_key: "jdx-package-#{name}") do |_dependent, dep|
Dependency.prune if dep.test? || dep.optional?
Dependency.prune if dep.name == "rustup" && args.without_yjit?
Dependency.prune if !args.without_yjit? && (dep.name.start_with?("glibc@") || dep.name == "linux-headers@4.4")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The condition !args.without_yjit? is re-evaluated for every dependency within this loop. For better readability and a minor performance improvement, consider hoisting this check out of the Dependency.expand block.

You could define a variable like yjit_enabled = !args.without_yjit? before the args.named.each loop and use it here:

Dependency.prune if yjit_enabled && (dep.name.start_with?("glibc@") || dep.name == "linux-headers@4.4")

@jdx jdx merged commit c5046d9 into main Mar 25, 2026
9 checks passed
@jdx jdx deleted the fix/jdx-package-dep-resolution branch March 25, 2026 15:01
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.

1 participant