Skip to content

macOS install script uses invalid group root instead of wheel leading to chown: root: illegal group name #618

@BTC-Tim

Description

@BTC-Tim

On macOS, the install.sh script fails when run with sudo because it attempts to chown the installed mailpit binary to group root, which does not exist on macOS. This causes:

chown: root: illegal group name
ERROR: Setting ownership for "/usr/local/bin/mailpit" binary.
There was an error installing Mailpit.

The script already has logic to set the group to wheel on Darwin, but due to a case mismatch in the OS variable it never takes effect.


Environment

  • OS: macOS (Darwin)

  • Install method:

    sudo sh < <(curl -sL https://raw.githubusercontent.com/axllent/mailpit/develop/install.sh)

Steps to reproduce

  1. On macOS, run:

    sudo sh < <(curl -sL https://raw.githubusercontent.com/axllent/mailpit/develop/install.sh)
  2. Wait for the script to download and attempt to install mailpit into /usr/local/bin.

  3. Observe the error during the chown step.


Actual behavior

Installer fails with:

chown: root: illegal group name
ERROR: Setting ownership for "/usr/local/bin/mailpit" binary.
There was an error installing Mailpit.

The ownership of the installed binary is not set and the script exits with a non‑zero status.


Expected behavior

On macOS, the installer should succeed and set the binary’s owner to root and group to wheel, without error.


Root cause analysis

In install.sh:

  • OS is initially set from uname -s:

    case "$(uname -s)" in
      Linux) OS="linux" ;;
      Darwin) OS="Darwin" ;;
      *)
        echo "OS not supported."
        exit 2
        ;;
    esac
  • Later, when setting the group for chown, the script checks:

    case "$OS" in
      darwin) GROUP="wheel" ;;
      *) ;;
    esac

Because OS is set to Darwin (capital D) but the case pattern is darwin (lowercase d), the darwin) branch never matches. As a result, GROUP remains root, and on macOS chown root:root fails with illegal group name.


Proposed fix

Normalize the OS name for Darwin to darwin so that the later case matches and the group is correctly set to wheel.

Change:

Darwin) OS="Darwin" ;;

to:

Darwin) OS="darwin" ;;

With this change, the script correctly executes:

OWNER="root"
GROUP="root"
case "$OS" in
  darwin) GROUP="wheel" ;;
  *) ;;
seac

chown "${OWNER}:${GROUP}" "$INSTALL_BIN_PATH"

On macOS this becomes:

chown root:wheel /usr/local/bin/mailpit

which succeeds.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions