Setting environment variables on OS X

后端 未结 30 3268
你的背包
你的背包 2020-11-21 05:15

What is the proper way to modify environment variables like PATH in OS X?

I\'ve looked on Google a little bit and found three different files to edit:

30条回答
  •  自闭症患者
    2020-11-21 05:39

    On Mountain Lion all the /etc/paths and /etc/launchd.conf editing doesn't make any effect!

    Apple's Developer Forums say:

    "Change the Info.plist of the .app itself to contain an "LSEnvironment" dictionary with the environment variables you want.

    ~/.MacOSX/environment.plist is no longer supported."

    So I directly edited the application's Info.plist (right click on "AppName.app" (in this case SourceTree) and then "Show package contents").

    Show Package Contents

    And I added a new key/dict pair called:

    LSEnvironment
    
         PATH
         /Users/flori/.rvm/gems/ruby-1.9.3-p362/bin:/Users/flori/.rvm/gems/ruby-1.9.3-p362@global/bin:/Users/flori/.rvm/rubies/ruby-1.9.3-p326/bin:/Users/flori/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:
    
    

    (see: LaunchServicesKeys Documentation at Apple)

    Enter image description here

    Now the application (in my case Sourcetree) uses the given path and works with Git 1.9.3 :-)

    PS: Of course you have to adjust the Path entry to your specific path needs.

提交回复
热议问题