Skip to content

Instantly share code, notes, and snippets.

@daggerok
Last active December 27, 2023 06:50
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save daggerok/d6c7ed8b9efa03b30ffd0e9f44cdd121 to your computer and use it in GitHub Desktop.
Save daggerok/d6c7ed8b9efa03b30ffd0e9f44cdd121 to your computer and use it in GitHub Desktop.
Install MacPorts 2.5.3 without sudo / root privileges
# install
mkdir ~/macports
cd ~/macports
curl -O https://distfiles.macports.org/MacPorts/MacPorts-2.5.3.tar.bz2
tar xf MacPorts-2.5.3.tar.bz2
cd MacPorts-2.5.3/
./configure --enable-readline --prefix=$HOME/macports --with-no-root-privileges
make && make install
# bash / zsh
echo "export MACPORTS_HOME=\\$HOME/macports" >> ~/.bash_profile
echo "export PATH=\\$MACPORTS_HOME/bin:\\$MACPORTS_HOME/sbin" >> ~/.bash_profile
# fish
echo "set -gx MACPORTS_HOME \\$HOME/macports" >> ~/.config/fish/config.fish
echo "set -gx PATH $MACPORTS_HOME/bin $MACPORTS_HOME/sbin" >> ~/.config/fish/config.fish
@gwhammett
Copy link

gwhammett commented Sep 12, 2022

Thanks for this! Very helpful.
This probably works for most people, except that lines 12-13 should be changed to something like:

echo "export MACPORTS_HOME=\$HOME/macports" >> ~/.bash_profile
echo "export PATH=\$PATH:\$MACPORTS_HOME/bin:\$MACPORTS_HOME/sbin" >> ~/.bash_profile

(and maybe something similar for the fish shell section.)

I had additional problems on my Mac trying to use your instructions for installing without sudo root privileges, because my group name is different than my user name. The macports install scripts appear to allow one to install with a particular group name using a "--with-install-group=[groupname]" option to config, but one of the scripts nevertheless tries to create a file with the group name set to be the same as the user name. Going to Preferences, Users & Groups, I had to create a new group with the same name as my user name, add my user name to that group, and then the install scripts worked okay. I would like to report this to macports, but I don't have time to put together a detailed bug report. Using Homewbrew to install what I needed worked fine, so I'll stick with that.

@jeanas
Copy link

jeanas commented Jan 8, 2023

It might be helpful to update the version. Current one is 2.8.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment