11

after installing mac ports my .profile looks like this:

# MacPorts Installer addition on 2011-12-04_at_20:48:26: adding an appropriate PATH variable for use with MacPorts.

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

# Finished adapting your PATH environment variable for use with MacPorts.

But for some reason when opening the terminal, or connecting to the server remotely (ssh) the .profile is not loaded so I can't use macports (unless i go to the macports folder of course).

How can I activate .profile?

Erik
  • 213
  • 2
  • 7

2 Answers2

20

From man bash (assuming it is your shell, type echo $0 or echo $SHELL at the prompt to find out):

When bash is invoked as an interactive login shell, [...] it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable.

Make sure you don't have either of the first two files, and if you do, add source .login to them. Alternatively, just add the export line to the preferred file.


Other shells probably have similar mechanics of preferring the shell program specific files to the more generic .profile.

Daniel Beck
  • 109,300
  • 14
  • 287
  • 334
  • 1
    Thanks a lot, I didn't realize it would only execute the commands in the first file. Added source .profile in my .bash_profile and it works a lot better! Thanks – Erik Dec 10 '11 at 18:52
  • .bashrc is another file to add to the list – Peter Jan 14 '13 at 20:00
  • @Pete `.bashrc` gets loaded by *non-login* sessions. A common configuration is to have one loaded by the other though. On OS X, all shells launched by Terminal are login shells by default, different from e.g. common Linux terminal emulators. – Daniel Beck Jan 14 '13 at 20:12
1

To update, try this: /opt/local/bin/port selfupdate

To run a sudo command like this: sudo port install somePackageYouNeed

Try: sudo /opt/local/bin/port install somePackageYouNeed

codingt
  • 11
  • 1