Permissions for local MacPorts repositories
Getting local Portfile repository for MacPorts running is difficult, if not annoying. The documentation doesn't provide much help or, worse, is even outdated. Hopefully, the following steps will help avoiding the problem I had.
Download and run the MacPorts installer
Unlike specified in the documentation, the installer did not add
PATHenvironmental variable. However, since I don't use the default macOS shell, the problem might actually be on my end.
# Bash or Zsh
set -Ux PATH /opt/local/bin $PATH
- To edit or add new Portfiles, you likely want to clone macports/macports-ports first. Througout this chapter, I will refer to my local Portfile repository as
git clone firstname.lastname@example.org:macports/macports-ports ~/Development/ports
/etc/macports/sources.confto add your local Portfile repository path. Make sure you add it _before the rsync URL.
- To avoid permission errors, we will also edit
macportsuserwill be set. The relevant line is commented by default. The following works for me, but then again I don't really know what I'm doing.
# User to run operations as when MacPorts drops privileges.
- As a last step, you need to index your local Portfile repository.
Note: If you haven't cloned macports/macports-ports and work with your own files, make sure to place your Portfile into the correct folder structure. MacPorts expects your Portfile to be in any of the predefined categories (e.g.
That's it. You should now be able to add or edit Portfiles and have the correct permissions to run
sudo port test or
sudo port -vst install.
Please let me know in the comments, if you have any suggestions on how to improve this guide!