On my Mac I use an Admin and an everyday User account (without admin / sudo privileges). Currently I am setting up a new Yosemite system and found that after installing MacPorts (using its installer), I cannot do sudo operations, such as sudo port selfupdate
. In the user account it tells me that it does not have sufficient privileges and on the admin account the command port
is not found.
So I am wondering what is the correct way to set up MacPorts on OS X? Should I install it rather on the Admin instead of the User account? Or is there some other way to use it from the User account?
Best Answer
Neither.
Macports is installed as root and uses its own account macports for some things. It does not use your account for anything.
To do MacPorts actions e.g. install, selfupdate you need to run it as root. Which in this case is run via sudo. So to do these actions you do need an admin account.
To use MacPorts executables or libraries you just need to add MacPorts to your user environment, which is the same for any user on your machine. e.g. add
/opt/local/bin
to $PATH to put the executables on your path, as described in the MacPorts manual.The one edge case is the install from the disk image which will run a script on your current user to add a line to your .bash_profile to set up your path.
You can also manually add the following line to your Admin's .bash_profile: