Setting environment variables via launchd.conf no longer works in OS X Yosemite/El Capitan/macOS Sierra/Mojave?

前端 未结 9 1390
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-22 08:07

It looks like the launchd.conf does not load my environment variable anymore. Has anyone else noticed that?

Is there another solution to permanently set

9条回答
  •  无人共我
    2020-11-22 08:36

    I added the variables in the ~/.bash_profile in the following way. After you are done restart/log out and log in

    export M2_HOME=/Users/robin/softwares/apache-maven-3.2.3
    export ANT_HOME=/Users/robin/softwares/apache-ant-1.9.4
    launchctl setenv M2_HOME $M2_HOME
    launchctl setenv ANT_HOME $ANT_HOME
    export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/robin/softwares/apache-maven-3.2.3/bin:/Users/robin/softwares/apache-ant-1.9.4/bin
    launchctl setenv PATH $PATH
    

    NOTE: without restart/log out and log in you can apply these changes using;

    source ~/.bash_profile
    

提交回复
热议问题