Strict Standards: Redefining already defined constructor for class wpdb in /var/www/www.sweeting.org/html/mark/blog/wp-includes/wp-db.php on line 52

Deprecated: Assigning the return value of new by reference is deprecated in /var/www/www.sweeting.org/html/mark/blog/wp-includes/cache.php on line 36

Strict Standards: Redefining already defined constructor for class WP_Object_Cache in /var/www/www.sweeting.org/html/mark/blog/wp-includes/cache.php on line 389

Strict Standards: Declaration of Walker_Page::start_lvl() should be compatible with Walker::start_lvl($output) in /var/www/www.sweeting.org/html/mark/blog/wp-includes/classes.php on line 537

Strict Standards: Declaration of Walker_Page::end_lvl() should be compatible with Walker::end_lvl($output) in /var/www/www.sweeting.org/html/mark/blog/wp-includes/classes.php on line 537

Strict Standards: Declaration of Walker_Page::start_el() should be compatible with Walker::start_el($output) in /var/www/www.sweeting.org/html/mark/blog/wp-includes/classes.php on line 537

Strict Standards: Declaration of Walker_Page::end_el() should be compatible with Walker::end_el($output) in /var/www/www.sweeting.org/html/mark/blog/wp-includes/classes.php on line 537

Strict Standards: Declaration of Walker_PageDropdown::start_el() should be compatible with Walker::start_el($output) in /var/www/www.sweeting.org/html/mark/blog/wp-includes/classes.php on line 556

Strict Standards: Declaration of Walker_Category::start_lvl() should be compatible with Walker::start_lvl($output) in /var/www/www.sweeting.org/html/mark/blog/wp-includes/classes.php on line 653

Strict Standards: Declaration of Walker_Category::end_lvl() should be compatible with Walker::end_lvl($output) in /var/www/www.sweeting.org/html/mark/blog/wp-includes/classes.php on line 653

Strict Standards: Declaration of Walker_Category::start_el() should be compatible with Walker::start_el($output) in /var/www/www.sweeting.org/html/mark/blog/wp-includes/classes.php on line 653

Strict Standards: Declaration of Walker_Category::end_el() should be compatible with Walker::end_el($output) in /var/www/www.sweeting.org/html/mark/blog/wp-includes/classes.php on line 653

Strict Standards: Declaration of Walker_CategoryDropdown::start_el() should be compatible with Walker::start_el($output) in /var/www/www.sweeting.org/html/mark/blog/wp-includes/classes.php on line 678

Deprecated: Assigning the return value of new by reference is deprecated in /var/www/www.sweeting.org/html/mark/blog/wp-includes/query.php on line 21

Deprecated: Assigning the return value of new by reference is deprecated in /var/www/www.sweeting.org/html/mark/blog/wp-includes/theme.php on line 507
Mac OS X Tip: Setting PATH environment variables
Strict Standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method GeoURL::tags() should not be called statically in /var/www/www.sweeting.org/html/mark/blog/wp-includes/plugin.php on line 160

Mac OS X Tip: Setting PATH environment variables

I’m still getting to grips with this OS X malarkey, and my latest challenge was how to set the PATH environment variables.

I started out wanting to add some aliases for the mysql and mysqladmin commands as I’ve just decided to have a bit of a play with django. On linux I used to edit my .bashrc file to do this, but the version of bash on Mac OS X (10.5.2) doesn’t seem to support this. Hunting around I realised that I should just add the path to these commands to my PATH environment variable, but again: not quite so simple.

I want these commands to be available to everyone, so it turns out you have to edit a file called paths in /etc:

sudo vi /etc/paths

And that was it. Easy when you know how! Oh, and remember to run vi as root using the sudo command….

Sociable:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • digg
  • Furl
  • NewsVine
  • Reddit
  • YahooMyWeb

9 Responses to “Mac OS X Tip: Setting PATH environment variables

  • Felipe
    July 31st, 2008 05:34
    1

    Hey there Mark.

    I just read this post, great info. But after digging a little I found out that you can use another method to do what you’re saying. You just have to create a file inside /etc/paths.d ; for instance if I’d like to append the mysql directory to the PATH I would do this:

    1) Create the file /etc/paths.d/mysql like this:
    sudo touch /etc/paths.d/mysql
    2) Edit the file:
    sudo vim /etc/paths.d/mysql
    3) Put the path inside the file:
    /usr/local/mysql/bin

    I posted three steps so everyone knows what they’re doing, but you could do it all by just creating the file and filling it with the path needed in PATH.

    I think this method works better because it is more ordered at the end and you would have a file for each path you want to create for every program that needs it.

    Hope this helps.
    Cheers. Felipe.

  • sirus
    November 24th, 2008 14:17
    2

    On Mac OS X exists a file that has the same role of the ~/.bashrc file on Linux and it’s the ~/.bash_profile file.

  • Marla
    February 12th, 2009 19:12
    3

    Thank you both! I’m also from unix but could find no dot file in my home dir where I set my path, but looking at the value of PATH, I obviously HAD modified it at least once in the past! Sure enough, I had added something under paths.d, just four months ago, too.

    What also drives me crazy is that when I search using spotlight, it ignores everything under /etc. Guess I have to go back to using good old find from / if I really want to find things related to system administration.

  • Jyothirmayee
    March 9th, 2009 11:37
    4

    Mark, Thanks so much for sharing this.

    After almost 2 days I landed on your blog. I wonder why most of the top results in google are misleading and there is nothing that is easily found on apple developers section either. You saved my day!

  • Russell
    May 16th, 2009 06:48
    5

    Additional info…

    The path value in the file in Felipe’s step 3 above is a clean/plain text path, not the path you’d type in a shell to set the PATH environment variable.

    I used this technique for a path that had spaces in one of the folder names and when I had the backslash escapes, it wasn’t working. Removing the backslashes made it work like a charm.

    Instead of these:
    export PATH=$PATH:/Developer/Applications/PLT\ Scheme\ v4.1.5/bin
    /Developer/Applications/PLT\ Scheme\ v4.1.5/bin

    Use just this:
    /Developer/Applications/PLT Scheme v4.1.5/bin

    Regards,
    -Russell

  • Werner
    July 27th, 2009 16:11
    6

    Mark and Felipe,

    many thanks! This helped me with an issue of webkit-image, a unix tool used for the JOSM editor of OpenStreetMap!

    Cheers,
    Werner

  • Cheule
    December 26th, 2009 17:00
    7

    The good thing about using a profile configuration file like .bashrc, is that if you ever migrate your home folder to a new machine/OS X install, all your changes go with you. If you edit things in /etc you are unlikely you retain such changes.

    The place to put such changes in OS X 10.4 / 10.5 / 10.6 is in ~/.profile . Specifically, I added the line “export PATH=$PATH:~/bin” (no quotes) to my ~/.profile file in order to allow me to install binaries into ~/bin.

  • Luc
    July 3rd, 2010 13:35
    8

    Thanks Felipe. There are many different ways to change PATH at startup, but this is the one I like most. (I’m using OS X 10.6.) Just one thing: the path in the file mysql has to end with a newline, otherwise it won’t be added properly to PATH.

    Cheers
    Luc

  • Jess
    September 19th, 2010 15:43
    9

    Hey Mark -

    You said:
    > On linux I used to edit my .bashrc file to do this, but the version of bash on Mac OS X (10.5.2) doesn’t seem to support this

    This isn’t exactly true. the .bashrc file is still used for executable shells in OSX, however it’s he .bash_profile that is used in login shells (like the Terminal). You’ll want to edit to add paths, like this:

    export PATH=$PATH:/usr/local/mysql/bin

    regards

Leave a Reply