Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#21625 closed defect (worksforme)

.bash_profile $PATH handled incorrectly

Reported by: curtis_ovid_poe@… Owned by: macports-tickets@…
Priority: Normal Milestone:
Component: base Version: 1.8.0
Keywords: Cc:
Port:

Description

After upgrading to Snow Leopard, I upgraded Mac Ports and discovered my $PATH was corrupted. In checking my .bash_profile, I discovered this:

# MacPorts Installer addition on 2009-09-08_at_09:58:50: 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.

There were two problems with this. First, I already had /opt/local/bin in my path, so now it's there twice. Second, I keep $HOME/bin in my path first. That's because I need to ensure that my programs take precedence over what's installed. What I would like to see is:

  • Don't add directories already in the path. If the user has added them, assume they know what they are doing (if /opt/local/bin isn't first in the path, maybe emit a warning to the user letting them know the consequences?)
  • If I have $HOME/bin first in my path, it's because I want $HOME/bin first in my path. Please leave it there :)

Cheers, Ovid

Change History (6)

comment:1 Changed 15 years ago by curtis_ovid_poe@…

Cc: curtis_ovid_poe@… added

Cc Me!

comment:2 Changed 15 years ago by mf2k (Frank Schima)

Cc: curtis_ovid_poe@… removed
Component: portsbase

comment:3 in reply to:  description ; Changed 15 years ago by blb@…

Replying to curtis_ovid_poe@…:

There were two problems with this. First, I already had /opt/local/bin in my path, so now it's there twice.

Where are you currently setting this? The installer should be checking PATH and only updating your dotfiles when it doesn't see MacPorts' paths.

  • If I have $HOME/bin first in my path, it's because I want $HOME/bin first in my path. Please leave it there :)

Note that the initial install will put it first on PATH (when MacPorts' paths aren't already there) and is doing that quite on purpose.

comment:4 in reply to:  3 ; Changed 15 years ago by curtis_ovid_poe@…

Replying to blb@…:

Replying to curtis_ovid_poe@…:

There were two problems with this. First, I already had /opt/local/bin in my path, so now it's there twice.

Where are you currently setting this? The installer should be checking PATH and only updating your dotfiles when it doesn't see MacPorts' paths.

This was set in my .bash_profile. I had to set in manually because when I first started using Mac Ports (a couple of years ago), I was still not getting those ports first in my path. I later installed Snow Leopard, I had a number of corruption issues and had to reistall Mac Ports. Regrettably, I was fixing so many issues that I can't tell you the steps to recreate this.

  • If I have $HOME/bin first in my path, it's because I want $HOME/bin first in my path. Please leave it there :)

Note that the initial install will put it first on PATH (when MacPorts' paths aren't already there) and is doing that quite on purpose.

The implication is that somehow the $PATH got wiped out during my upgrade and the /opt/local/bin wasn't in my path when Mac Ports was reinstalled. I don't know how this could have happened, but it sounds like you are doing the right thing (so long as my $PATH is correct).

comment:5 in reply to:  4 Changed 15 years ago by blb@…

Resolution: worksforme
Status: newclosed

Replying to curtis_ovid_poe@…:

This was set in my .bash_profile. I had to set in manually because when I first started using Mac Ports (a couple of years ago), I was still not getting those ports first in my path. I later installed Snow Leopard, I had a number of corruption issues and had to reistall Mac Ports. Regrettably, I was fixing so many issues that I can't tell you the steps to recreate this.

There was a bug in older versions of the MacPorts package that would fail to update the PATH properly, perhaps that was the source of that issue? Also, note that reinstalling MacPorts when upgrading to 10.6 (or any major OS version update) is actually the proper method to use.

The implication is that somehow the $PATH got wiped out during my upgrade and the /opt/local/bin wasn't in my path when Mac Ports was reinstalled. I don't know how this could have happened, but it sounds like you are doing the right thing (so long as my $PATH is correct).

If /opt/local/bin wasn't found in PATH at the time of a new install, that would definitely explain why it decided to update your PATH. If you do find that that isn't working correctly, say so and I'll reopen the ticket.

comment:6 Changed 15 years ago by autumnmist@…

When I upgraded to 10.6 I ended up having problems with /opt/local/* ending up before /usr/bin which messed up a number of my scripts.

To upgrade to 10.6 Macports from 10.5 Macports, I completely uninstalled Macports (using this method http://trac.macports.org/wiki/Migration). I ended up not using Macports for a little while so only reinstalled a few ports a few days ago. Then I realized that my path was messed up and fixing it in .bashrc and .profile didn't help. After finding curtis_ovid's post, I realized that Macports was taking precedence in .bash_profile and proceeded to edit it and insert /usr/bin first.

I don't know if this information will help or not but I definitely did a complete uninstall and then reinstall and ended up with the same problem.

Note: See TracTickets for help on using tickets.