GH#951: add bin/check-env.sh prerequisite check script#952
Conversation
…list Adds a runnable bash script that checks all development prerequisites in one pass (PHP, composer, npm, wp-cli, WordPress dev env, WP test suite, xdebug) and prints actionable fix instructions for anything missing. Updates AGENTS.md Quick Session Checklist item 4 to surface this script as the first thing to run, consolidating the individual inline checks that were scattered across the section. Rationale: five documentation-only PRs (#920, #929, #933, #944, #949) have already strengthened the written guidance for the four recurring error patterns in issue #951. The remaining gap for bash:other is converting the prerequisite check from prose instructions into a runnable script that exits 1 on failure, so agents can detect missing tools without reading multiple documentation sections. Resolves #951
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 47 minutes and 45 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📝 WalkthroughWalkthroughThis PR consolidates environment prerequisites checking by introducing Changes
Possibly related PRs
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
🔨 Build Complete - Ready for Testing!📦 Download Build Artifact (Recommended)Download the zip build, upload to WordPress and test:
🌐 Test in WordPress Playground (Very Experimental)Click the link below to instantly test this PR in your browser - no installation needed! Login credentials: |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
bin/check-env.sh (1)
46-60: Consider downgradingwpand../wordpressto warnings (or scoping by workflow) rather than hard failures.WP-CLI and the
../wordpressdev install are only required forwp ...commands and full integration scenarios; PHPUnit, PHPCS/PHPStan, ESLint/Stylelint, andnpm run checkall run without them. Treating them as[!!](withexit 1) means a contributor who just wants to run the test suite or lint will see the script declare the environment "not ready" even though every test/lint command would succeed — the same pattern the PR is trying to avoid.Two options, in order of preference:
- Treat them like xdebug —
note/infooutput, no contribution toany_fail. Matches the optional nature documented in AGENTS.md "WP-CLI and Bash Prerequisites" section (line 320+).- Split into "Required for tests/lint" (PHP, vendor, node_modules, WP test suite) and "Required for WP-CLI" (wp, ../wordpress) groups, and only fail when the corresponding group is needed (e.g., via a
--wp-cliflag or env var).♻️ Minimal diff for option 1 (treat as optional notes)
-# 4. WP-CLI +# 4. WP-CLI (optional — only needed for wp commands) if command -v wp >/dev/null 2>&1; then - ok "wp-cli found: $(wp --version --allow-root 2>/dev/null || echo "(version unknown)")" + note "wp-cli found: $(wp --version --allow-root 2>/dev/null || echo "(version unknown)")" else - fail "wp-cli not in PATH" + note "wp-cli NOT in PATH (optional) — only needed for wp commands" info "Install: https://wp-cli.org/#installing (download wp-cli.phar and add to PATH)" fi -# 5. WordPress dev install +# 5. WordPress dev install (optional — only needed for wp commands) if [ -f "../wordpress/wp-config.php" ]; then - ok "WordPress dev install found at ../wordpress" + note "WordPress dev install found at ../wordpress" else - fail "WordPress dev install missing at ../wordpress" + note "WordPress dev install missing at ../wordpress (optional) — only needed for wp commands" info "Fix: cd ../wordpress && ./reset.sh (or clone the dev WP install there)" fi🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@bin/check-env.sh` around lines 46 - 60, The checks that call command -v wp and test -f "../wordpress/wp-config.php" currently call fail and thus mark the environment as unusable; change these to optional checks by converting the fail/ok logic into informational notes (use info or note) and ensure they do not update any_fail (or the same failure flag used elsewhere), or alternatively add a --wp-cli/ENV flag to gate these checks so the wp CLI checks (the command -v wp block and the ../wordpress/wp-config.php block) only run and can fail when that flag is set; update the messages around those blocks (wp --version output and the WordPress dev install message) to reflect optional status when not required.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@bin/check-env.sh`:
- Around line 1-22: The script currently runs relative-path checks from the
caller's CWD and can falsely report missing files; add a working-directory guard
at the top of bin/check-env.sh that resolves the script location and either cd's
to the repo root (parent of bin) before performing checks or prints a clear
error and exits; implement this by computing a SCRIPT_DIR (using the script's
path via $0), deriving REPO_ROOT as the parent directory, and changing to
REPO_ROOT before any calls to ok(), fail(), info(), or note() so all subsequent
path-based checks (e.g., vendor/autoload.php, node_modules/.bin/eslint,
../wordpress/wp-config.php) run from the intended repo root.
---
Nitpick comments:
In `@bin/check-env.sh`:
- Around line 46-60: The checks that call command -v wp and test -f
"../wordpress/wp-config.php" currently call fail and thus mark the environment
as unusable; change these to optional checks by converting the fail/ok logic
into informational notes (use info or note) and ensure they do not update
any_fail (or the same failure flag used elsewhere), or alternatively add a
--wp-cli/ENV flag to gate these checks so the wp CLI checks (the command -v wp
block and the ../wordpress/wp-config.php block) only run and can fail when that
flag is set; update the messages around those blocks (wp --version output and
the WordPress dev install message) to reflect optional status when not required.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: ecd1dfc7-803d-4a2a-a707-695eae88562e
📒 Files selected for processing (2)
AGENTS.mdbin/check-env.sh
|
Performance Test Results Performance test results for 0e2f951 are in 🛎️! Note: the numbers in parentheses show the difference to the previous (baseline) test run. Differences below 2% or 0.5 in absolute values are not shown. URL:
|
Addresses CodeRabbit review: path-based checks (vendor/, node_modules/, ../wordpress/) are relative to CWD, which caused spurious failures if the script was invoked from a subdirectory or editor task with a non-root CWD. The guard computes the repo root from the script's own location and cd's to it before performing any checks, so the output is always correct regardless of where the caller's working directory was.
🔨 Build Complete - Ready for Testing!📦 Download Build Artifact (Recommended)Download the zip build, upload to WordPress and test:
🌐 Test in WordPress Playground (Very Experimental)Click the link below to instantly test this PR in your browser - no installation needed! Login credentials: |
Summary
Adds
bin/check-env.sh— a single runnable script that verifies all development prerequisites (PHP, composer vendor, node_modules, wp-cli, WordPress dev env, WP test suite, xdebug) in one pass and prints actionable fix instructions for anything missing.Updates
AGENTS.mdQuick Session Checklist item 4 to surfacebash bin/check-env.shas the recommended first step before any lint/test/WP-CLI command.Why
Issue #951 (and predecessors #919, #928, #932, #940, #943, #948) report 4 recurring error patterns:
webfetch:other(39x),read:file_not_found(35x),bash:other(34x), andedit:not_read_first(32x) from contributor superdav42's sessions.Five documentation-only PRs have already addressed the written guidance for all four patterns. The remaining gap for
bash:otheris that prerequisite checks are documented as prose across multiple AGENTS.md sections — agents must read and mentally track several individual checks. Converting these into a runnable script with exit codes makes the check mechanical and unambiguous.What changed
bin/check-env.sh(new): checks PHP,vendor/autoload.php,node_modules/.bin/eslint,wpin PATH,../wordpress/wp-config.php,/tmp/wordpress-tests-lib, and xdebug. Exits 0 on all-pass, 1 on any required-check failure. xdebug is optional and shown as[--]rather than[!!].AGENTS.mdQuick Session Checklist item 4: addsbash bin/check-env.shas the first recommended check, with the existing individual checks kept as the fallback.Testing
Resolves #951
aidevops.sh v3.11.7 plugin for OpenCode v1.3.17 with claude-sonnet-4-6 spent 9m and 24,117 tokens on this as a headless worker.
Summary by CodeRabbit
New Features
Documentation