Migrate CLI implementation to Rust#30
Conversation
|
Warning Review limit reached
More reviews will be available in 46 minutes and 41 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, 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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughThis PR completes a language migration from Nim to Rust. The core resolution algorithm, CLI, project manifest, and all CI/CD workflows (GitHub Actions, Nix, Docker, Homebrew) transition to Rust equivalents, while build artifact ignores are updated for the new system. ChangesNim-to-Rust migration
Sequence DiagramsequenceDiagram
participant User as why_core
participant Origin as find_origin_path
participant Symlink as resolve_symlink_chain
participant Detect as detect_provider_by_path
participant PkgMgr as check_system_package_manager
participant Result as WhyResult
User->>Origin: locate command
Origin-->>User: origin_path
User->>Symlink: expand symlinks
Symlink-->>User: real_path
User->>Detect: match rules
Detect-->>User: provider
alt provider unknown
User->>PkgMgr: query systems
PkgMgr-->>User: attributed provider
end
User->>Result: build result
Result-->>User: WhyResult or WhyError
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
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 |
There was a problem hiding this comment.
Actionable comments posted: 6
🧹 Nitpick comments (1)
tests/e2e/Builder.Dockerfile (1)
1-1: ⚡ Quick winPin the Rust builder image to a digest.
rust:1.90-bookwormwill drift as upstream images are rebuilt, so E2E failures become harder to reproduce and the exact toolchain provenance is lost.Example
-FROM rust:1.90-bookworm +FROM rust:1.90-bookworm@sha256:<published-digest>🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/e2e/Builder.Dockerfile` at line 1, The FROM line uses the mutable tag rust:1.90-bookworm; replace it with the corresponding immutable digest (e.g. rust@sha256:...) to pin the builder image so the Rust toolchain no longer drifts — locate the FROM instruction referencing "rust:1.90-bookworm" in Builder.Dockerfile and update it to the image digest form fetched from the upstream registry.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/ci.yml:
- Around line 25-31: Replace unpinned, tag-based GH Actions and enable
non-persisted checkout for the Nix step: pin dtolnay/rust-toolchain,
Swatinem/rust-cache, cachix/install-nix-action and actions/checkout references
to specific commit SHAs (not tags) and in the checkout step used for Nix set
persist-credentials: false; update any existing uses of actions/checkout@v4 to
the pinned SHA and add persist-credentials: false under the checkout step that
prepares the Nix environment so the auth token is not persisted.
In @.github/workflows/release.yml:
- Around line 55-56: Update the "Cache Cargo" step that uses
Swatinem/rust-cache@v2 to make the cache read-only for the tag-triggered release
workflow by adding the input flag to disable saving (set save-if: false) under
the step's with: section so the action will not write or update the cache during
this privileged job.
- Around line 50-56: Replace the mutable action tags in the release workflow
with pinned commit SHAs: change dtolnay/rust-toolchain@stable,
Swatinem/rust-cache@v2, and softprops/action-gh-release@v2 to their respective
commit SHA refs so the workflow uses exact commits instead of tags;
additionally, for the Swatinem/rust-cache step (the action named "Cache Cargo")
add the configuration to disable writes (e.g., set the save-if / restore-only
equivalent such as with: save-if: "false" or the action's restore-only option)
so the release run only restores cache and never updates it.
In `@README.md`:
- Around line 133-139: Replace the incorrect markdown link syntax in the bash
example so the git clone command is a valid shell command: change the line
containing "git clone
[https://github.com/akriaueno/why-cli.git](https://github.com/akriaueno/why-cli.git)"
to use a plain URL after git clone (i.e., `git clone
https://github.com/akriaueno/why-cli.git`) so copy/pasting the README's setup
steps works as intended.
In `@src/core.rs`:
- Around line 348-355: The check that decides to use the Flatpak fallback
incorrectly treats explicit paths like "/usr/bin/ls" as missing because
file_name(&origin_path) != command_name; update the conditional in
find_origin_path so it first detects if the original command_name is an explicit
path (contains path separator or starts with '.'), and only perform the
file_name comparison or call find_flatpak_fallback when command_name is not a
path; in other words, skip the file_name(&origin_path) != command_name branch
for explicit paths and fallback to flatpak only when origin_path.is_empty() or
the non-path command's file_name doesn't match.
- Around line 66-72: The pattern list used by detect_provider_by_path contains a
case-mismatched entry "/usr/local/cellar" which will not match Intel macOS
Homebrew installs; update the patterns array (the patterns variable used in
detect_provider_by_path in src/core.rs) to use the correct casing
"/usr/local/Cellar" so the path comparison can match Intel Homebrew prefixes.
---
Nitpick comments:
In `@tests/e2e/Builder.Dockerfile`:
- Line 1: The FROM line uses the mutable tag rust:1.90-bookworm; replace it with
the corresponding immutable digest (e.g. rust@sha256:...) to pin the builder
image so the Rust toolchain no longer drifts — locate the FROM instruction
referencing "rust:1.90-bookworm" in Builder.Dockerfile and update it to the
image digest form fetched from the upstream registry.
🪄 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: 8b2c3130-ced5-40ca-8c77-a5493cf3a378
⛔ Files ignored due to path filters (2)
Cargo.lockis excluded by!**/*.locknimble.lockis excluded by!**/*.lock
📒 Files selected for processing (17)
.dockerignore.github/scripts/generate_formula.sh.github/workflows/ci.yml.github/workflows/release.yml.gitignoreCargo.tomlREADME.mdnix/nim-lock.jsonnix/package.nixsrc/core.rssrc/main.rssrc/why.nimsrc/why_core.nimsrc/why_os.nimtests/e2e/Builder.Dockerfiletests/test_why_core.nimwhy_cli.nimble
💤 Files with no reviewable changes (6)
- why_cli.nimble
- src/why.nim
- src/why_core.nim
- tests/test_why_core.nim
- src/why_os.nim
- nix/nim-lock.json
Summary
whybinaryubuntu-24.04-armrunnerTesting
cargo fmt --checkcargo clippy --all-targets -- -D warningscargo test --lockednix buildnix shell nixpkgs#actionlint -c actionlint./tests/e2e/run.shSummary by CodeRabbit
Documentation
./target/release/whyBuild Infrastructure