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 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 be on my end.
# Bash or Zsh export PATH=/opt/local/bin:$PATH` # Fish 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 email@example.com:macports/macports-ports ~/Development/ports
/etc/macports/sources.confto add your local Portfile repository path. Make sure you add it _before the rsync URL.
file:///Users/<YOUR_USERNAME>/Development/ports rsync://rsync.macports.org/macports/release/tarballs/ports.tar [default]
- 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. macportsuser root
- As a last step, you need to index your local Portfile repository.
cd ~/Development/ports portindex
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!