Skip to content

fix: os detection & pkg installer COMMON_DEPS#13

Merged
0xdilshan merged 2 commits into
mainfrom
dev
Mar 2, 2026
Merged

fix: os detection & pkg installer COMMON_DEPS#13
0xdilshan merged 2 commits into
mainfrom
dev

Conversation

@0xdilshan

@0xdilshan 0xdilshan commented Mar 2, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Bug Fixes

    • Improved Linux distribution detection for broader compatibility
    • Added validation to ensure sudo is available on Linux with clear error on failure
    • Strengthened error handling and messaging across package installation flows
  • Improvements

    • Streamlined Homebrew initialization on macOS using dynamic environment evaluation
    • Adjusted package manager invocations and sequencing for more reliable installs
    • Unified dependency install behavior (macOS excludes zsh; dependencies now installed unconditionally)
    • Miscellaneous formatting and flow refinements

@coderabbitai

coderabbitai Bot commented Mar 2, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d88d438 and 0e09fff.

📒 Files selected for processing (1)
  • install.sh

📝 Walkthrough

Walkthrough

The install script improves distro-family detection (handles space-separated ID_LIKE and more derivatives), adds a Linux sudo preflight check, standardizes package-manager invocations and error paths, refactors macOS Homebrew shellenv handling, and adjusts COMMON_DEPS so macOS excludes zsh while ensuring a final unconditional COMMON_DEPS install.

Changes

Cohort / File(s) Summary
Installer script
install.sh
Expanded _resolve_distro_family to parse space-separated ID_LIKE and additional derivatives; retained macOS family exceptions. Added Linux preflight check to verify sudo exists. Standardized package manager calls and error messaging for Debian, Arch, Fedora, SUSE, and macOS. Replaced explicit Homebrew shellenv logic with dynamic evaluation. Adjusted COMMON_DEPS so macOS excludes zsh, added a final unconditional install_pkg call for COMMON_DEPS. Minor formatting and sequencing tweaks across install flows.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Installer as install.sh
  participant Sudo as sudo
  participant PM as PackageManager
  participant Brew as Homebrew
  participant FS as Filesystem

  User->>Installer: run install.sh
  Installer->>Installer: detect OS / resolve distro family (parse ID_LIKE)
  alt Linux
    Installer->>Sudo: check existence
    Sudo-->>Installer: present / absent
    Installer->>PM: run install_pkg (COMMON_DEPS + distro-specific)
    PM-->>Installer: install result
  else macOS
    Installer->>Brew: evaluate `brew shellenv`
    Brew-->>Installer: env and prefix
    Installer->>Brew: install_pkg (COMMON_DEPS without zsh)
    Brew-->>Installer: install result
  end
  Installer->>FS: install fonts/configs
  Installer-->>User: finish (success / error)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 I hopped through shells and distro trees,
parsing ID_LIKE on the breeze.
I checked for sudo, brewed some cheer,
installed deps both far and near—
a nimble script, with fluffy ease. 🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly references the main changes: OS detection improvements and COMMON_DEPS handling in the package installer.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev

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.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
install.sh (1)

242-242: ⚠️ Potential issue | 🟡 Minor

Inconsistent: -y is still used with apt-get update here.

Line 113 correctly removed -y from apt-get update (with a comment noting it's invalid), but this line still uses -y with update. Apply the same fix for consistency.

Proposed fix
-            sudo apt-get update -qq -y > /dev/null && sudo apt-get install -qq -y eza > /dev/null
+            sudo apt-get update -qq > /dev/null && sudo apt-get install -qq -y eza > /dev/null
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@install.sh` at line 242, Update the shell command that currently reads "sudo
apt-get update -qq -y > /dev/null && sudo apt-get install -qq -y eza >
/dev/null" to remove the invalid "-y" from the apt-get update invocation (so
only the install uses "-y"); keep the "-qq" and redirections intact and ensure
the resulting command is "sudo apt-get update -qq > /dev/null && sudo apt-get
install -qq -y eza > /dev/null".
🧹 Nitpick comments (1)
install.sh (1)

121-123: Consider -S instead of -Sy to avoid partial upgrade risk.

Using pacman -Sy without -u can lead to partial upgrades, which is discouraged in the Arch ecosystem. If the goal is simply to install packages (assuming the user's system is already up-to-date), consider using -S alone. If you intentionally want to refresh the database, the current approach is acceptable but carries some risk.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@install.sh` around lines 121 - 123, The pacman invocation uses "-Sy" which
can cause partial-upgrade risk; update the sudo pacman command that installs
"${pkgs[@]}" (the line starting with sudo pacman -Sy -q --noconfirm --needed) to
use "-S" instead of "-Sy" if you only intend to install packages, or explicitly
use "-Syu" when you intend to refresh and upgrade the system; ensure the
replacement preserves the existing flags (-q --noconfirm --needed) and the
failure handling block around that command.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@install.sh`:
- Around line 100-104: The error message in the sudo availability check (the
conditional using OS_TYPE and command -v sudo) contradicts the script's earlier
refusal to run as root (unless CI_ENV=true); change the echo to only recommend
installing sudo or configuring CI_ENV=true for CI runs (remove "or run as
root"), or alternatively update the logic to allow root by checking UID==0 and
proceeding when appropriate; specifically modify the sudo-check block that
references OS_TYPE and CI_ENV so the message and behavior are consistent with
the root-rejection logic elsewhere.

---

Outside diff comments:
In `@install.sh`:
- Line 242: Update the shell command that currently reads "sudo apt-get update
-qq -y > /dev/null && sudo apt-get install -qq -y eza > /dev/null" to remove the
invalid "-y" from the apt-get update invocation (so only the install uses "-y");
keep the "-qq" and redirections intact and ensure the resulting command is "sudo
apt-get update -qq > /dev/null && sudo apt-get install -qq -y eza > /dev/null".

---

Nitpick comments:
In `@install.sh`:
- Around line 121-123: The pacman invocation uses "-Sy" which can cause
partial-upgrade risk; update the sudo pacman command that installs "${pkgs[@]}"
(the line starting with sudo pacman -Sy -q --noconfirm --needed) to use "-S"
instead of "-Sy" if you only intend to install packages, or explicitly use
"-Syu" when you intend to refresh and upgrade the system; ensure the replacement
preserves the existing flags (-q --noconfirm --needed) and the failure handling
block around that command.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 01b9168 and d88d438.

📒 Files selected for processing (1)
  • install.sh

Comment thread install.sh
Comment on lines +100 to +104
# Verify sudo is available on Linux before attempting privileged installs
if [[ "$OS_TYPE" == "linux" ]] && ! command -v sudo &>/dev/null; then
echo -e "${RED}sudo is required but not found. Please install sudo or run as root.${NC}"
exit 1
fi

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Contradictory error message regarding root execution.

The message suggests "run as root" as an alternative, but the script explicitly rejects root execution at lines 27-31 (unless CI_ENV=true). This could confuse users on minimal systems without sudo.

Proposed fix
 if [[ "$OS_TYPE" == "linux" ]] && ! command -v sudo &>/dev/null; then
-    echo -e "${RED}sudo is required but not found. Please install sudo or run as root.${NC}"
+    echo -e "${RED}sudo is required but not found. Please install sudo first.${NC}"
     exit 1
 fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@install.sh` around lines 100 - 104, The error message in the sudo
availability check (the conditional using OS_TYPE and command -v sudo)
contradicts the script's earlier refusal to run as root (unless CI_ENV=true);
change the echo to only recommend installing sudo or configuring CI_ENV=true for
CI runs (remove "or run as root"), or alternatively update the logic to allow
root by checking UID==0 and proceeding when appropriate; specifically modify the
sudo-check block that references OS_TYPE and CI_ENV so the message and behavior
are consistent with the root-rejection logic elsewhere.

@0xdilshan 0xdilshan merged commit e68b517 into main Mar 2, 2026
2 of 3 checks passed
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