Skip to content

Comments

fix: add support for non-Debian Linux package managers#401

Open
yurekami wants to merge 1 commit intounslothai:mainfrom
yurekami:fix/multi-distro-package-managers
Open

fix: add support for non-Debian Linux package managers#401
yurekami wants to merge 1 commit intounslothai:mainfrom
yurekami:fix/multi-distro-package-managers

Conversation

@yurekami
Copy link
Contributor

Summary

  • Added support for multiple Linux distributions beyond Debian/Ubuntu and RHEL/Fedora:
    • Arch Linux (pacman)
    • Gentoo (emerge)
    • Alpine Linux (apk)
    • openSUSE (zypper)
  • Enhanced check_linux_type() to detect these distributions
  • Updated install_package() and do_we_need_sudo() to use the appropriate package manager
  • Improved error messages when package managers are not found, directing users to documentation

Related Issue

Fixes #251

Test plan

  • Test on Debian/Ubuntu (apt-get)
  • Test on RHEL/Fedora/CentOS (yum/dnf)
  • Test on Arch Linux (pacman)
  • Test on Gentoo (emerge)
  • Test on Alpine (apk)
  • Test on openSUSE (zypper)
  • Test on unknown distribution (graceful error message)

🤖 Generated with Claude Code

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @yurekami, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the software's compatibility across a wider range of Linux distributions. By integrating support for several new package managers and improving distribution detection, it aims to provide a more robust and user-friendly experience for users on various Linux environments, while also offering clearer guidance in case of installation issues.

Highlights

  • Expanded Linux Distribution Support: Added support for Arch Linux (pacman), Gentoo (emerge), Alpine Linux (apk), and openSUSE (zypper) package managers, significantly broadening compatibility beyond Debian/Ubuntu and RHEL/Fedora.
  • Enhanced Distribution Detection: The check_linux_type() function has been updated to accurately detect the newly supported Linux distributions.
  • Improved Package Management Logic: The install_package() and do_we_need_sudo() functions now correctly utilize the appropriate package manager commands for the detected system type.
  • Refined Error Handling: Error messages for cases where package managers are not found have been improved, providing clearer guidance and directing users to relevant documentation for manual installation.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

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

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 significantly improves support for various Linux distributions by adding detection and package installation logic for Arch, Gentoo, Alpine, and openSUSE. The changes are well-structured, and the error messages are more informative. I've provided a few suggestions to improve maintainability and robustness by refactoring some duplicated code and making the distribution detection more consistent. Overall, this is a great enhancement.

Comment on lines 189 to 193
pkg_mgr_names = {
"rpm": "yum/dnf", "arch": "pacman", "gentoo": "emerge",
"alpine": "apk", "suse": "zypper", "debian": "apt-get"
}
pkg_mgr_name = pkg_mgr_names.get(system_type, "package manager")
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This pkg_mgr_names dictionary is duplicated in the do_we_need_sudo function (lines 244-248). To follow the DRY (Don't Repeat Yourself) principle and improve maintainability, you should define this dictionary as a module-level constant (e.g., PKG_MGR_NAMES) and use it in both places.

You can define the constant at the top of the file like so:

PKG_MGR_NAMES = {
    "rpm": "yum/dnf", "arch": "pacman", "gentoo": "emerge",
    "alpine": "apk", "suse": "zypper", "debian": "apt-get"
}
                pkg_mgr_name = PKG_MGR_NAMES.get(system_type, "package manager")

Comment on lines 215 to 232
# Choose update command based on system type
if system_type == "rpm":
pkg_manager = "yum" if os.path.exists('/usr/bin/yum') else "dnf"
update_cmd = f"{pkg_manager} check-update"
else:
elif system_type == "arch":
update_cmd = "pacman -Sy"
elif system_type == "gentoo":
update_cmd = "emerge --sync"
elif system_type == "alpine":
update_cmd = "apk update"
elif system_type == "suse":
update_cmd = "zypper refresh"
elif system_type == "unknown":
# For unknown systems, skip the update check and assume sudo is needed
print("Unsloth: Unknown Linux distribution, skipping package manager check")
return True
else: # Default to debian/apt-get
update_cmd = "apt-get update -y"
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For better maintainability and readability, you can refactor this long if/elif chain into a dictionary lookup. This makes it easier to add or modify support for package managers in the future.

    # Choose update command based on system type
    if system_type == "unknown":
        # For unknown systems, skip the update check and assume sudo is needed
        print("Unsloth: Unknown Linux distribution, skipping package manager check")
        return True

    update_commands = {
        "arch":   "pacman -Sy",
        "gentoo": "emerge --sync",
        "alpine": "apk update",
        "suse":   "zypper refresh",
        "debian": "apt-get update -y",
    }

    if system_type == "rpm":
        pkg_manager = "yum" if os.path.exists('/usr/bin/yum') else "dnf"
        update_cmd = f"{pkg_manager} check-update"
    else:
        # Default to debian for any unhandled system type, which is the original behavior.
        update_cmd = update_commands.get(system_type, update_commands["debian"])

Comment on lines 244 to 248
pkg_mgr_names = {
"rpm": "yum/dnf", "arch": "pacman", "gentoo": "emerge",
"alpine": "apk", "suse": "zypper", "debian": "apt-get"
}
pkg_mgr_name = pkg_mgr_names.get(system_type, "package manager")
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

As mentioned in the comment for the install_package function, this dictionary is duplicated. Please replace it with a reference to the new module-level constant PKG_MGR_NAMES to adhere to the DRY principle.

                pkg_mgr_name = PKG_MGR_NAMES.get(system_type, "package manager")

Comment on lines +1309 to +1310
elif os.path.exists('/etc/SuSE-release') or os.path.exists('/etc/SUSE-brand'):
return 'suse'
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For consistency with the detection logic for other distributions like Arch and Gentoo, you should also check for the existence of the zypper executable. This makes the detection more robust, especially in cases where the release files might be missing or in non-standard locations.

    elif os.path.exists('/etc/SuSE-release') or os.path.exists('/etc/SUSE-brand') or os.path.exists('/usr/bin/zypper'):
        return 'suse'

Copy link

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

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines 152 to 153
elif system_type == "arch":
install_cmd = f"{sudo_prefix}pacman -S --noconfirm {package}"

Choose a reason for hiding this comment

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

P1 Badge Handle libcurl dev package names on new distros

On Arch/Gentoo/Alpine/openSUSE, check_linux_type() now returns those system types, but check_libcurl_dev() still falls through to the Debian default and returns libcurl4-openssl-dev for any non‑debian/rpm system. With the new branches here, that Debian package name is passed directly to pacman/emerge/apk/zypper, which will report “package not found” and abort installation. This means the newly advertised distro support will still fail whenever libcurl headers are missing. You likely need distro-specific libcurl package mapping (e.g., curl/libcurl-devel/curl-dev) before invoking these package managers.

Useful? React with 👍 / 👎.

Extends package manager support beyond Debian/apt-get and RPM/yum to include:
- Arch Linux (pacman)
- Alpine Linux (apk)
- openSUSE (zypper)
- Gentoo (emerge)

Changes:
- Updated check_linux_type() to detect additional distributions
- Added _get_pkg_manager_info() helper for update commands
- Added _get_install_cmd() helper for install commands
- Added _get_package_names_for_system() for distro-specific package names
- Updated check_libcurl_dev() to check packages on all supported distros

This allows users on non-Debian/RPM systems to use GGUF conversion
without encountering "apt-get does not exist" errors.

Fixes unslothai#251

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@yurekami yurekami force-pushed the fix/multi-distro-package-managers branch from 8a18a5d to 2abc040 Compare December 29, 2025 18:54
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.

RuntimeError: [FAIL] Unsloth: apt-get does not exist? Is this NOT a Linux / Mac based computer?

1 participant