Skip to content

fix: skip Homebrew dependency for skill install on Linux (#14593)#55940

Open
lupuletic wants to merge 3 commits intoopenclaw:mainfrom
lupuletic:fix/skill-install-brew-linux-14593
Open

fix: skip Homebrew dependency for skill install on Linux (#14593)#55940
lupuletic wants to merge 3 commits intoopenclaw:mainfrom
lupuletic:fix/skill-install-brew-linux-14593

Conversation

@lupuletic
Copy link
Copy Markdown
Contributor

Summary

  • When kind: "brew" skill install runs on Linux without Homebrew, fall back to apt-get install <formula> (root or passwordless sudo) before giving up
  • Follows the existing installGoViaApt pattern already used for go kind installs
  • On macOS (or Linux without apt-get), behavior is unchanged -- the existing "brew not installed" error is returned
  • Closes [Bug]: Skill install fails in Docker: brew not installed on Linux container #14593

Test plan

  • Added 6 new tests in skills-install-fallback.test.ts covering: root apt install, sudo apt install, apt failure, no apt-get available, sudo password required, macOS no-fallback
  • pnpm check passes (lint, typecheck, format)
  • pnpm test -- src/agents/skills-install-fallback.test.ts passes (9/9)
  • pnpm test -- src/agents/skills-install.test.ts passes (2/2)

AI-Assisted PR Checklist:

  • Marked as AI-assisted
  • Testing degree: fully tested
  • Code reviewed by LLM
  • I understand what the code does

🤖 Generated with Claude Code

@openclaw-barnacle openclaw-barnacle bot added agents Agent runtime and tooling size: M labels Mar 27, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 27, 2026

Greptile Summary

This PR adds a best-effort apt-get fallback for kind: \"brew\" skill installs on Linux when Homebrew is not available, following the existing installGoViaApt pattern. The feature is gated behind process.platform === \"linux\" && hasBinary(\"apt-get\"), so macOS and non-Debian Linux environments are unaffected.\n\n- New installBrewFormulaViaApt function mirrors installGoViaApt almost exactly: checks for root, probes sudo with -n true, runs apt-get update -qq (best-effort), then apt-get install -y <formula>.\n- Call site in installSkill correctly slots the fallback before resolveBrewMissingFailure, with input already validated by buildInstallCommand.\n- 6 new tests cover the happy paths (root, sudo) and all failure modes (apt failure, no apt-get, sudo password, macOS no-op).\n- Minor: the formula string is not trimmed inside installBrewFormulaViaApt (unlike the brew path which uses spec.formula.trim()); installBrewFormulaViaApt and installGoViaApt are ~50-line near-duplicates that could share a generic helper; and the && spec.formula guard at the call site is redundant after buildInstallCommand validation.

Confidence Score: 5/5

Safe to merge — the fallback is correctly gated and fails gracefully; all identified issues are minor style concerns.

No P0 or P1 issues found. Formula validation is already enforced upstream via buildInstallCommand/SAFE_BREW_FORMULA before installBrewFormulaViaApt is called, the apt commands are passed as argument arrays (no shell interpolation), the sudo probe pattern is reused from the audited installGoViaApt path, and the new tests cover all meaningful branches.

No files require special attention beyond the P2 style notes in skills-install.ts.

Important Files Changed

Filename Overview
src/agents/skills-install.ts Adds installBrewFormulaViaApt to fall back to apt-get on Linux when Homebrew is absent. Correctly reuses the root/sudo pattern from installGoViaApt. Minor issues: formula should be trimmed inside the helper, the new function duplicates ~50 lines from installGoViaApt, and the && spec.formula guard is redundant.
src/agents/skills-install-fallback.test.ts Adds 6 focused tests covering the new brew-to-apt fallback: root install, sudo install, apt failure, no apt-get, sudo password required, and macOS no-op. Tests correctly override process.platform with a proper afterEach restore. Assertions match actual error messages produced by installBrewFormulaViaApt.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/agents/skills-install.ts
Line: 302

Comment:
**Formula not trimmed before passing to apt-get**

`buildInstallCommand` uses `spec.formula.trim()` for the brew invocation (line 149), but `installBrewFormulaViaApt` receives and uses the formula as-is. `assertSafeInstallerValue` validates the *trimmed* value, so a formula stored with leading/trailing whitespace (e.g. `" openai-whisper "`) would pass validation and then be forwarded to apt-get untrimmed — causing a package-not-found failure.

```suggestion
  const aptInstallArgv = ["apt-get", "install", "-y", formula.trim()];
  const aptUpdateArgv = ["apt-get", "update", "-qq"];
```

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: src/agents/skills-install.ts
Line: 298-347

Comment:
**Significant duplication with `installGoViaApt`**

`installBrewFormulaViaApt` (50 lines) is structurally identical to `installGoViaApt` (51 lines) — same root-check, same sudo probe, same `runBestEffortCommand` for `apt-get update`, same error shape. The only differences are the package name and the failure message strings.

Consider extracting a shared `installViaApt(pkg, failureMessage, timeoutMs)` helper and calling it from both functions to avoid the duplication and make future maintenance easier.

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: src/agents/skills-install.ts
Line: 547

Comment:
**Redundant `spec.formula` guard**

`buildInstallCommand` (called a few lines above on line 530) already returns an error and exits early if `spec.formula` is missing or invalid. By the time execution reaches this line, `spec.formula` is guaranteed to be a non-empty, validated string. The `&& spec.formula` check is harmless but unnecessary clutter.

```suggestion
    if (process.platform === "linux" && hasBinary("apt-get")) {
```

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "fix: fall back to apt-get for brew skill..." | Re-trigger Greptile

@lupuletic lupuletic force-pushed the fix/skill-install-brew-linux-14593 branch from 007f851 to abf5539 Compare March 27, 2026 21:07
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: abf5539586

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@lupuletic lupuletic force-pushed the fix/skill-install-brew-linux-14593 branch from abf5539 to a2cf27b Compare March 27, 2026 21:40
@lupuletic lupuletic force-pushed the fix/skill-install-brew-linux-14593 branch from a2cf27b to dd9f6b8 Compare March 28, 2026 06:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Skill install fails in Docker: brew not installed on Linux container

1 participant