简体   繁体   中英

how to set environment variables in Yosemite

This question has been asked before but the solutions assume that you are acquainted with OS X, unfortunately I'm not, so please bear with me. I would like to use qmake from the terminal command. With Yosemite, I'm not able to find an easy way to do it. The solution is suggested here but I can't figure out how to use it. The solution is as follows

In previous releases of OS X (Mavericks, Mountain Lion, Lion, ...), environment variables are configured in the /etc/launchd.conf file. As of OS X Yosemite, this is no longer working. To configure environment variables, you can do the following

$ nano ~/Library/LaunchAgents/my.startup.plist

my.startup.plist

 <?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>Label</key> <string>my.startup</string> <key>ProgramArguments</key> <array> <string>sh</string> <string>-c</string> <string>launchctl setenv $VARIABLE_NAME $VARIABLE_VALUE</string> </array> <key>RunAtLoad</key> <true/> </dict> </plist> 

In my case, the path to qmake is /Users/XXXX/Qt/5.4/clang_64/bin , what should I do so that the qmake will be recognized in the terminal command?

Terminal sessions use the shell. You only should modify shell environment variables, there is no need to reconfigure GUI programs.

Also, I don't suppose the .plist offers a way to extend a preexisting variable.

You could use ~/.profile :

export PATH=$PATH:~XXXX/Qt/5.4/clang_64/bin

If Qt offers a more canonical method of installation, that would probably be preferable, though.


If you literally just want the command qmake to work, without really installing anything, just do

sudo ln -s ~/Qt/5.4/clang_64/bin/qmake /usr/local/bin

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM