Mac OS X Lion no longer recognizes environment.plist?

前端 未结 10 1216
挽巷
挽巷 2020-12-09 02:38

Just installed Lion today and my PATH env variable is no longer being set by ~/.MacOSX/environment.plist. Did something change? Can\'t seem to find any info on that or how t

相关标签:
10条回答
  • 2020-12-09 03:12

    I recently packaged up tools used by Xcode's Run Script Phase and placed them in $HOME/bin. My bash shell's PATH environment variable included this, so I assumed the Xcode would too.

    It never worked and I found issues like the one here.

    I printed the PATH variable from the script (echo $PATH) called by Xcode to see what the PATH variable was set to.

    Fortunately, one of those paths, /Applications/Xcode.app/Contents/Developer/usr/local/bin was never used.

    Here was my solution. I created a symbolic link from the above directory to $HOME/bin.

    Navigate to /Applications/Xcode.app/Contents/Developer/usr/local and execute sudo ln -s $HOME/bin bin.

    My tools were now available to the Xcode platform.

    0 讨论(0)
  • 2020-12-09 03:17

    Do it like brew and create a symlink in /usr/local/bin/. Works perfectly for me and is IMO a more unix-like solution where everything is a file.

    0 讨论(0)
  • 2020-12-09 03:18

    I ran into the same issue today. I called Apple Support and after being escalated to a Senior Advisor, then to her supervisor, I was told that they no longer support environment.plist and that there is no officially-supported method for defining environment variables in Mac OS 10.7.

    0 讨论(0)
  • 2020-12-09 03:19

    I just got burned by something similar in Snow Leopard, and then figured out what the problem was.

    I was doing:

    $ cd
    $ defaults write .MacOSX/environment FOO bar
    

    ...but it turns out that this is different from doing (in my case):

    $ cd
    $ defaults write /Users/ljnelson/.MacOSX/environment FOO bar
    

    That is, the "path" (it's not really a path) to your domain must be the full file path to your $HOME/.MacOSX/environment.plist file (minus the .plist suffix). Anything else will write variables to a different domain (no idea where it got put), apparently.

    So, upshot: always do defaults write /full/path/to/your/.MacOSX/environment VARNAME value; don't use any shortcuts at all for the first argument to the write subcommand.

    0 讨论(0)
  • 2020-12-09 03:20

    Whether or not Apple officially supports this mechanism, the current tech note Technical Q&A QA1067 is still accurate. An important caveat, however, is absent: the Property List needs to be in binary format. Xcode 4, when used to create new Property Lists, emits files that are in the text format (regardless of the type specified in File Inspector). So you either need to convert the saved file using 'plutil':

    plutil -convert binary1 environment.plist
    

    or use 'defaults' to write out a new, template file that you can edit in Xcode (which will honor the original binary format when saving):

    defaults write defaults write $HOME/.MacOSX/environment Root "1"
    
    0 讨论(0)
  • 2020-12-09 03:20

    You can edit your ~/.MacOSX/environment.plist with this example of $PATH:

    defaults write $HOME/.MacOSX/environment PATH "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin:/opt/local/bin"
    

    This will rewrite your ~/.MacOSX/environment.plist

    or edit this file:

    /etc/paths
    

    to change the order of system variables.

    0 讨论(0)
提交回复
热议问题