44

I have attempted to install MacPorts in order to upgrade my Rails version so that I can work my way through Agile Web Development with Rails, PragProg (4th, 2011). I have followed the directions in the book, as well as on the MacPorts web site, to perform the install from disk image. It appeared to install correctly, however, running port commands afterwards returned "port: command not found".

I searched Stack Exchange and found this question, so I attempted to install from the command line using "tar xjvf MacPorts-1.9.2.tar.bz2". Again, the install seems to work. I receive the confirmation that MacPorts installed successfully, but I still receive "sudo: port: command not found" error on trying to selfupdate MacPorts (via "sudo port -v selfupdate").

I think that my error lies in not having the correct path set. I followed the advice in this thread, namely, adding a path (/opt/local) in paths.d, but I still get the error.

If it matters, terminal is set to open shells with default login shell (/usr/bin/login). Should I change this to /bin/bash?

So, is this a MacPorts issue, a $PATH issue, or a StupidUser issue?

5 Answers 5

62

It is probably a PATH issue.

By default port is installed the directory /opt/local/bin. Add the path 'opt/local/bin' as an extra line to the plain text file /etc/paths and you should be good.

54

You can also add the following line to your ~/.bash_profile:

export PATH=$PATH:/opt/local/bin

This will add /opt/local/bin to the executable path and make your port command available to the shell.

4
  • 1
    I created .bash_profile and added export PATH=$PATH:/opt/local/bin export MANPATH=$MANPATH:/opt/local/share/man export INFOPATH=$INFOPATH:/opt/local/share/info lines...but still it's giving me same problem..i am using OS version 10.8.3 .any suggestion?
    – CoDe
    Jul 28, 2013 at 12:48
  • I'll just add that you have to restart your computer.
    – Baldráni
    Aug 28, 2016 at 19:28
  • 1
    @Baldráni no need to restart. Try - source ~/.bash_profile
    – markroxor
    Jan 19, 2019 at 5:39
  • I don't think this works, because sudo runs as root on a different environment Apr 5 at 16:17
8

open a terminal, then write:

sudo nano /etc/paths

write your password

then copy and paste in to the bottom:

/opt/local/bin

save the file:

alt + x and then y

Restart the computer.

3

this is working for me:

first open this file with nano

sudo nano ~/.bash_profile

if it doesnt exist create it manually or with

touch ~/.bash_profile

add this line to the file

export PATH=$PATH:/opt/local/bin

now reload .bash_profile

source ~/.bash_profile
0

Thanks so much, I was running into the same issue and I ended up adding the below line to my .bash_profile file (I am on Ventura macOS)

export PATH="/opt/local/bin:$PATH"
2
  • Please don't add "thank you" as an answer. Once you have sufficient reputation, you will be able to vote up questions and answers that you found helpful. - From Review Jan 29, 2023 at 9:52
  • Welcome to Super User! Before answering an old question having an accepted answer (look for green ✓) as well as other answers ensure your answer adds something new or is otherwise helpful in relation to them. Here is a guide on How to Answer. There is also a site tour and a help center. Jan 29, 2023 at 9:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .