Skip to content

fix: improve local binary build robustness - #1324

Merged
shunkakinoki merged 1 commit into
mainfrom
fix/build-script-robustness
Apr 1, 2026
Merged

fix: improve local binary build robustness#1324
shunkakinoki merged 1 commit into
mainfrom
fix/build-script-robustness

Conversation

@shunkakinoki

@shunkakinoki shunkakinoki commented Apr 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • asupersync: Makefile has no build target but has Cargo.toml — now falls through to cargo when make build target doesn't exist
  • symphony: mise.toml not trusted — now auto-runs mise trust before mise install
  • submodules: Init git submodules before building if .gitmodules exists
  • beads: Missing ICU C headers for CGo — now provides PKG_CONFIG_PATH/CGO_CFLAGS/CGO_LDFLAGS via nix icu.dev
  • pi_agent_rust: Broken orphaned submodule (no .gitmodules entry) — upstream issue, can't fix

Test plan

  • make shell-test passes (no new failures)
  • make format clean (0 changed)

🤖 Generated with Claude Code


Summary by cubic

Make local binary builds more robust. Adds a make fallback to cargo, auto-trusts mise.toml, initializes submodules, and wires ICU headers for CGo.

  • Bug Fixes
    • If Makefile has no build target, fall back to cargo build --release when Cargo.toml exists.
    • Run mise trust before mise install when mise.toml is present.
    • Initialize git submodules when .gitmodules exists.
    • For go projects needing ICU, set PKG_CONFIG_PATH, CGO_CFLAGS, and CGO_LDFLAGS via nix icu/icu.dev.

Written for commit 1fa3d8b. Summary will update on new commits.

- Fall through to Cargo.toml when Makefile has no build target (fixes asupersync)
- Auto-trust mise.toml before installing tools (fixes symphony)
- Init git submodules before building if .gitmodules exists
- Provide ICU headers via nix for CGo builds (fixes beads)
Copilot AI review requested due to automatic review settings April 1, 2026 13:17
@shunkakinoki
shunkakinoki merged commit 5ea3ff9 into main Apr 1, 2026
27 checks passed
@shunkakinoki
shunkakinoki deleted the fix/build-script-robustness branch April 1, 2026 13:17
@coderabbitai

coderabbitai Bot commented Apr 1, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e07169ee-8646-4919-8b35-7f4a51896dd1

📥 Commits

Reviewing files that changed from the base of the PR and between d7b52b4 and 1fa3d8b.

📒 Files selected for processing (1)
  • scripts/update-local-binaries.sh

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.


📝 Walkthrough

Summary by CodeRabbit

  • Chores
    • Enhanced build script to better support Git submodules and improve Makefile detection and execution.
    • Improved Go project building with enhanced compatibility for ICU-related dependencies.
    • Refined tool installation process with additional validation steps for improved reliability.

Walkthrough

The script now adds mise trust verification before installation, conditionally initializes git submodules, checks for Makefile build targets before execution (with fallback warnings), and optionally injects ICU compilation settings for Go builds via nix-build environment variables.

Changes

Cohort / File(s) Summary
Build System Enhancements
scripts/update-local-binaries.sh
Added mise trust step before installation; conditional git submodule initialization; Makefile build target detection with warning fallback; optional ICU compilation setup for Go via nix-build and environment variables (PKG_CONFIG_PATH, CGO_CFLAGS, CGO_LDFLAGS).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • feat: add local binaries update system #629: Modifies the same scripts/update-local-binaries.sh script with related build system logic changes (Makefile handling, build target checks, and build behavior enhancements).

Suggested labels

bug

Poem

🐰 The build script now trusts and verifies,
Git submodules spring to life with pride,
Make targets checked before we try,
Go's ICU path opens wide,
One script, many systems unified! 🔨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/build-script-robustness

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mesa-dot-dev

mesa-dot-dev Bot commented Apr 1, 2026

Copy link
Copy Markdown

Mesa Description

TL;DR

Improved robustness of local binary builds for various projects by addressing issues like missing build targets, untrusted mise.toml files, uninitialized git submodules, and missing CGo headers.

What changed?

  • asupersync: Added fallback to cargo when make build target is not found in Makefile.
  • symphony: Automatically runs mise trust before mise install for mise.toml.
  • submodules: Initializes git submodules if .gitmodules exists before building.
  • beads: Provided PKG_CONFIG_PATH/CGO_CFLAGS/CGO_LDFLAGS via nix icu.dev to resolve missing ICU C headers for CGo.
  • pi_agent_rust: Acknowledged a broken orphaned submodule as an upstream issue, no fix implemented.

Description generated by Mesa. Update settings

@mesa-dot-dev mesa-dot-dev Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Performed full review of d7b52b4...1fa3d8b

Analysis

• Build system priority logic has shifted—when Makefile exists but lacks a build target, the system now falls through to attempt Cargo/Go builds. This changes the original clear priority hierarchy (Makefile → Cargo → Go) and could cause multiple build attempts in hybrid projects, wasting resources and creating ambiguous error states.

• Build-time requirements are accumulating in a bash script (mise trust, git submodules, ICU headers, Nix dependencies) without structured orchestration. The function is growing in complexity and this scattered approach makes it difficult to test, maintain, and understand actual build prerequisites. This belongs in a more disciplined build configuration layer.

• ICU header setup introduces a hard Nix dependency into the build script, creating an assumption that Nix is available and configured. While the codebase appears Nix-based, this tightens coupling and reduces portability without clear documentation of this requirement.

Tip

Help

Slash Commands:

  • /review - Request a full code review
  • /review latest - Review only changes since the last review
  • /describe - Generate PR description. This will update the PR body or issue comment depending on your configuration
  • /help - Get help with Mesa commands and configuration options

0 files reviewed | 1 comments | Edit Agent SettingsRead Docs

elif [ -f "$build_dir/Cargo.toml" ]; then
fi

if [ -f "$build_dir/Cargo.toml" ]; then

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 control flow change from elif to if means that if a Makefile exists but has no build target, the script will now try both Cargo.toml AND go.mod builds (if both exist). This could lead to confusing behavior where multiple build systems are attempted for the same project. Consider adding early returns or making the checks mutually exclusive to maintain the original intent of trying one build system at a time.

Fix in Cursor • Fix in Claude

Prompt for Agent
Task: Address review feedback left on GitHub.
Repository: shunkakinoki/dotfiles#1324
File: scripts/update-local-binaries.sh#L174
Action: Open this file location in your editor, inspect the highlighted code, and resolve the issue described below.

Feedback:
The control flow change from `elif` to `if` means that if a Makefile exists but has no build target, the script will now try both Cargo.toml AND go.mod builds (if both exist). This could lead to confusing behavior where multiple build systems are attempted for the same project. Consider adding early returns or making the checks mutually exclusive to maintain the original intent of trying one build system at a time.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 1 file

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

Copy link
Copy Markdown
Contributor

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 enhances the update-local-binaries.sh script by adding support for mise trust, initializing git submodules, and improving build system fallback logic when a Makefile lacks a build target. It also introduces automated detection and configuration of ICU dependencies for Go builds using Nix. I have no feedback to provide.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Improves the robustness of scripts/update-local-binaries.sh when building a variety of local repos by adding safer fallbacks and pre-build setup steps (mise trust/install, submodule init, and Go ICU env support).

Changes:

  • Run mise trust before mise install when mise.toml is present.
  • Initialize git submodules automatically when .gitmodules exists.
  • If a Makefile lacks a build target, fall through to Cargo/Go builds; additionally provide ICU-related env vars for Go/CGo builds via Nix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +142 to 143
(cd "$build_dir" && mise trust 2>&1) || true
(cd "$build_dir" && mise install 2>&1) || true

Copilot AI Apr 1, 2026

Copy link

Choose a reason for hiding this comment

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

mise trust can require interactive confirmation; running it without a non-interactive flag risks hanging (or failing) and then mise install may still run with an untrusted mise.toml. Consider using a non-interactive option (e.g., --yes/equivalent) and/or only invoking trust when the file is currently untrusted.

Suggested change
(cd "$build_dir" && mise trust 2>&1) || true
(cd "$build_dir" && mise install 2>&1) || true
if (cd "$build_dir" && mise trust --yes 2>&1); then
(cd "$build_dir" && mise install 2>&1) || true
else
log_warn " Skipping mise install because 'mise trust' failed or was not confirmed"
fi

Copilot uses AI. Check for mistakes.
Comment on lines +181 to +186
# Provide ICU headers for CGo builds that need them (e.g. go-icu-regex)
local icu_dev
icu_dev="$(nix-build '<nixpkgs>' -A icu.dev --no-out-link 2>/dev/null || true)"
local icu_lib
icu_lib="$(nix-build '<nixpkgs>' -A icu --no-out-link 2>/dev/null || true)"
local go_env=()

Copilot AI Apr 1, 2026

Copy link

Choose a reason for hiding this comment

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

The nix-build '<nixpkgs>' ... calls run for every Go module, which can significantly slow down builds and may fail on flake-based setups where NIX_PATH/<nixpkgs> isn't configured. Consider guarding this behind command -v nix/nix-build, and/or only resolving ICU via Nix as a fallback retry when the initial go build fails due to missing ICU/pkg-config headers (or use nix build nixpkgs#icu{,.dev} to avoid relying on <nixpkgs>).

Copilot uses AI. Check for mistakes.
else
return 1
fi
else

Copilot AI Apr 1, 2026

Copy link

Choose a reason for hiding this comment

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

With the Makefile handling split into its own if, a repo that has a Makefile (but no build target) and also lacks Cargo.toml/go.mod will later hit the fallback branch that logs "No Makefile, Cargo.toml, or go.mod found". That warning becomes misleading; consider updating the fallback message or adding a dedicated fallback for the "Makefile present but no supported build targets/files" case.

Suggested change
else
else
log_warn " Makefile has no build target."
# If there is no Cargo.toml or go.mod either, there's nothing we know how to build here.
if [ ! -f "$build_dir/Cargo.toml" ] && [ ! -f "$build_dir/go.mod" ]; then
log_warn " Makefile has no 'build' target and no Cargo.toml or go.mod found; nothing to build in $build_dir."
return 1
fi

Copilot uses AI. Check for mistakes.
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