Sunday, March 27, 2011

environment path loading incorrectly in bash

I recently installed the Macports port of Ruby19 and it's changed my environment settings to point to opt/local in the first instance rather than usr/local where I have my standard 1.8.7 install.

I've tried updating my ~/.profile by adding the usual export PATH etc. as the last line but to no avail. I have to run the .profile file each time I open a new terminal window/tab and it's fast becoming a royal pita.

I'm fairly noob to OS X so can anyone point me in the right direction, please?

Is there a way to edit the environment.plist directly? Is there a better way to do this? As a side topic (if such things are allowed), can anyone recommend some good resources for learning more about the inner workings of OS X?

Thanks in advance.

From stackoverflow
  • I have never owned a Mac, but I am familiar with Linux. Since both are Unix, I guess there might be similarities. Try to add the usual 'export PATH' to '~/.bashrc' instead of '~/.profile'. This works on Linux, anyway.

    Edit: It seems like there are some differences between OS X and Linux. My advice does not seem to help solve the problem. Anyway, see here for a short description of each initialization script.

    Karl Yngve LervÄg : After some research I see that this does not help. Well, at least I tried :p
    Urf : Thanks for the answer anyway! Much appreciated.
  • The Missing Manual series is pretty good. I got one for OS X and refer to it when I need to do something that I know should be easy, but don't know how to do.

    Urf : Thanks Greg. Much appreciated. I haven't marked this as the correct answer as it only answers the manual part of the question. My bad for asking two questions at once!
  • It depends on when you want this setting to take place. If at the very beginning of your session, the place to put it is in ~/.MacOSX/environment.plist. That way, it will be available everywhere whether you are in a shell or not.

    EDIT: add example

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
      <dict>
        <key>CVS_RSH</key>
        <string>ssh</string>
      </dict>
    </plist>
    
    Urf : Thanks for the info Keltia. Unfortunately I couldn't find the ~/.MacOSX/environment.plist file (no doubt due to my lack of experience). However, I will follow this up so thanks for the advice.
    Keltia : Just create the directory & file.
    Urf : Thanks, Keltia. Much appreciated.
  • I don't appear to have a ~/.MacOSX/environment.plist file. Should I create one? Am I being stupid? ;)

  • bash on Mac OS X prefers '.bash_profile' instead of '.profile'. Try that.

    Urf : Perfect! Worked first time. Many thanks.

0 comments:

Post a Comment