Specify UserID and GroupID for MacPorts users, how can I do that?

Ryan Schmidt ryandesign at macports.org
Mon Nov 8 15:12:28 UTC 2021

> On Nov 8, 2021, at 04:00, FritzS GMX wrote:
> Which users (and their groups) are created by MacPorts and how can they be created during a new installation so that they get a UID (also GroupID) previously defined by me.
> Is there possibly a script suggestion that could be used before the MacPorts installation?
> I want to achieve UID's & GroupID's starting from 530.
> I want to install MacPorts on my new M1 MacMini with Monterey.
> From my old Mac with ElCapitan
> # _messagebus 512
> # avahi 511
> # ldap 500
> # macports 506
> # messagebus 508
> # named 509
> # pulse 510

MacPorts provides no method for you to influence which UIDs and GIDs it chooses when it creates new users and groups. It picks the next free number starting at 501. If you want to change that, you can modify the source.

If the user/group MacPorts wants to create already exists, MacPorts doesn't do anything, so one solution is for you to pre-create the users/groups you need with the desired IDs.

When you install MacPorts, it creates the "macports" user. If you use the pkg installer, the code that does this is here:


If you build from source, the code that does this is here:


You can change NEXTUID from 501 to something else if you want it to search for an unused ID starting at a different number.

Individual ports that you install may create their own users/groups. To find the ones that do, grep the Portfile for the commands "adduser", "addgroup" (the old commands) and "add_users" (the new command).

The code that creates these users/groups is here:


The constants MIN_USABLE_UID and MIN_USABLE_GID are defined here:


You can change MIN_USABLE_UID and MIN_USABLE_GID from 501 to something else if you want it to search for an unused ID starting at a different number. If you update MacPorts to a new version using selfupdate or our pkg installer these changes would be lost, so if you want to preserve this modification make sure you only update MacPorts base by building from your modified sources in the future.

More information about the macports-users mailing list